2.1.8.36 SystemTimeToFileTime


Description

Converts a system time to 64-bit file time

Syntax

BOOL SystemTimeToFileTime( const SYSTEMTIME * lpSystemTime, FILETIME * lpFileTime )

Parameters

lpSystemTime
[input] Pointer to a SYSTEMTIME structure that contains the time to be converted.
The wDayOfWeek member of the SYSTEMTIME structure is ignored.
lpFileTime
[output] Pointer to a FILETIME structure to receive the converted system time.

Return

If the function succeeds, the return value is true; else return false;

Examples

EX1

int SystemTimeToFileTime_ex1()
{
    string strFileName = "c:\\test.txt";
    BOOL bRet = FALSE;
    HANDLE hFile = CreateFile(strFileName, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
    if (hFile != INVALID_HANDLE_VALUE)
    {
        FILETIME ft;
        SYSTEMTIME st;
        GetSystemTime(&st);              // gets current time
        SystemTimeToFileTime(&st, &ft);  // converts to file time format
        bRet = SetFileTime(hFile,NULL, NULL, &ft);
        CloseHandle(hFile);
    }
    return 1;
}

Remark

See Also

SetFileTime, FileTimeToSystemTime

Header to Include

origin.h

Reference