CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2005
    Location
    Netherlands, The
    Posts
    2,184

    FILETIME to string

    is there any easy way in the api that can do this already?
    making it on my own with FileTimeToSystemTime and then putting all the vars in a string is kinda problem matic

  2. #2
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: FILETIME to string

    You could use sprintf or StringCchPrintf(). Here is an example from MSDN:
    Code:
    BOOL GetLastWriteTime(HANDLE hFile, LPTSTR lpszString, DWORD dwSize)
    {
        FILETIME ftCreate, ftAccess, ftWrite;
        SYSTEMTIME stUTC, stLocal;
        DWORD dwRet;
    
        // Retrieve the file times for the file.
        if (!GetFileTime(hFile, &ftCreate, &ftAccess, &ftWrite))
            return FALSE;
    
        // Convert the last-write time to local time.
        FileTimeToSystemTime(&ftWrite, &stUTC);
        SystemTimeToTzSpecificLocalTime(NULL, &stUTC, &stLocal);
    
        // Build a string showing the date and time.
        dwRet = StringCchPrintf(lpszString, dwSize, 
            TEXT("%02d/%02d/%d  %02d:%02d"),
            stLocal.wMonth, stLocal.wDay, stLocal.wYear,
            stLocal.wHour, stLocal.wMinute);
    
        if( S_OK == dwRet )
            return TRUE;
        else return FALSE;
    }
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  3. #3
    Join Date
    Aug 2005
    Location
    Netherlands, The
    Posts
    2,184

    Re: FILETIME to string

    except its not a date its a number of how many time has passed past.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured