COleDateTime::ParseDateTime issues under XP using VC++ 6.0
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: COleDateTime::ParseDateTime issues under XP using VC++ 6.0

  1. #1
    Join Date
    Sep 2003
    Posts
    1

    COleDateTime::ParseDateTime issues under XP using VC++ 6.0

    I have previously developed all my source code under VC++ 6.0 under windows 2000.

    I have upgraded my PC to XP and have now run into a problem using COleDateTime::ParseDateTime.

    Whereas the following code fragment was working fine under any non XP windows machine, it now no longer works.

    CString strDate;
    COleDateTime coDate;

    CTime tNow = CTime::GetCurrentTime();;
    strDate = tNow.Format("%Y/%m/%d %H:%M:%S");
    coDate.ParseDateTime(strDate);
    strDate.Format("%d/%d/%d %d:%d:%d",coDate.GetYear(), coDate.GetMonth(), coDate.GetDay(), coDate.GetHour(), coDate.GetMinute(), coDate.GetSecond());

    Whereas the COleDateTime variable coDate would be set to a valid date time via the ParseDateTime function, it is now no longer doing so under XP.

    Can anyone help?

    Many Thanks.

  2. #2
    Join Date
    Aug 2011
    Posts
    5

    Arrow Re: COleDateTime::ParseDateTime issues under XP using VC++ 6.0

    I am having same issue with my application it works fine in WIN 2k but not working oin WIN XP and code I worked is as follow:

    SetAvailability();


    COleDateTime timeStart;
    // COleDateTime timeEnd(30.0);
    COleDateTimeSpan timePassed;

    int daysLeft = 0;

    HKEY hk;
    DWORD dwDisp;

    // Open the Registry key, if it doesn't exist, it will be created.
    RegCreateKeyEx(HKEY_LOCAL_MACHINE,
    "SOFTWARE\\AVTRON MANUFACTURING\\ADDAPT\\PARAMETERS",
    0,
    NULL,
    REG_OPTION_NON_VOLATILE,
    KEY_WRITE | KEY_READ,
    NULL,
    &hk,
    &dwDisp);

    // Check to see if the product code has been set in the registry entry.
    int iRetValProdCode =
    RegQueryValueEx(hk,
    "USR:App Name\\ProductCode",
    NULL,
    NULL,
    NULL,
    NULL);

    CAddaptApp* pAddaptApp = (CAddaptApp*)AfxGetApp();

    if(iRetValProdCode != ERROR_SUCCESS)
    {
    DWORD cbData = sizeof(pAddaptApp->m_dwProductCode);

    RegQueryValueEx(hk,
    "USR:App Name\\ProductCode",
    NULL,
    NULL,
    (LPBYTE)&pAddaptApp->m_dwProductCode,
    &cbData);
    }

    if(iRetValProdCode != ERROR_SUCCESS || pAddaptApp->m_dwProductCode == 0)
    {

    // Check to see if the install date has been set in the registry entry. If it doesn't exist, create
    // the registry entry.

    int iRetVal = RegQueryValueEx(hk,
    "USR:App Name\\FirstInstallDateTime",
    NULL,
    NULL,
    NULL,
    NULL);

    COleDateTime currDateTime = COleDateTime::GetCurrentTime();

    if(iRetVal != ERROR_SUCCESS)
    {
    // Registry entry doesn't exist, create it, and set to the current date.
    RegSetValueEx(hk,
    "USR:App Name\\FirstInstallDateTime",
    0,
    REG_DWORD,
    (LPBYTE) &currDateTime,
    sizeof(currDateTime));
    }

    timeStart = COleDateTime::GetCurrentTime(); // Date and time of the installation.

    DWORD cbData = sizeof(timeStart);

    RegQueryValueEx(hk,
    "USR:App Name\\FirstInstallDateTime",
    NULL,
    NULL,
    (LPBYTE)&timeStart,
    &cbData);

    timePassed = COleDateTime::GetCurrentTime() - timeStart;
    daysLeft = 30 - static_cast<int>(timePassed.GetTotalDays());

    CString strMessage;

    if (daysLeft <= 0)
    {

    CProductCodeDlg dlg;
    dlg.DoModal();

    if(pAddaptApp->m_dwProductCode != 0)
    {
    // Create the product code registry entry.
    RegSetValueEx(hk,
    "USR:App Name\\ProductCode",
    0,
    REG_DWORD,
    (LPBYTE) &pAddaptApp->m_dwProductCode,
    sizeof(pAddaptApp->m_dwProductCode));

    }
    else
    {
    return FALSE;
    }

    }
    else
    {

    strMessage.Format(_T("ADDapt is operating under a trial license. \n")
    _T("You have %d" " days to activate ADDapt with a valid license.\n")
    _T("To activate, Please call Avtron Field Service at 000 000-1230 ext 1214. \n")
    _T("Do you want to Proceed?"), daysLeft);

    int iRespVal = AfxMessageBox(strMessage, MB_YESNO | MB_ICONEXCLAMATION);

    // User selected No, close the application.
    if(iRespVal == IDNO)
    {
    return FALSE;
    }
    }
    }

  3. #3
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,301

    Re: COleDateTime::ParseDateTime issues under XP using VC++ 6.0

    Quote Originally Posted by patelv61 View Post
    I am having same issue with my application it works fine in WIN 2k but not working on WIN XP
    What exactly is "not working oin WIN XP" of what worked "in WIN 2k"?

    Besides, you should use Code tags around your code snippet to make code formatted to easy read/understand it. See Announcement: Before you post....
    Last edited by VictorN; January 12th, 2012 at 04:58 PM.
    Victor Nijegorodov

  4. #4
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,525

    Re: COleDateTime::ParseDateTime issues under XP using VC++ 6.0

    Quote Originally Posted by patelv61 View Post
    I am having same issue with my application
    I couldn't find "ParseDateTime" in your code. How is it "same issue"?
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinViewer - an integrated GDI objects viewer for Visual C++ Debugger, and more...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center