对SYSTEMTIME加减操作

#define _SECOND ((ULONGLONG) 10000000)
#define _MINUTE (60 * _SECOND)
#define _HOUR   (60 * _MINUTE)
#define _DAY    (24 * _HOUR)

void CTestClass::ChangeTime(SYSTEMTIME& sysTime)
{ 
    GetLocalTime(&sysTime);

    FILETIME ft={0}; 
    SystemTimeToFileTime(&sysTime, &ft); 

    ULONGLONG qwResult;
    // Copy the time into a quadword.
    qwResult = (((ULONGLONG) ft.dwHighDateTime) << 32) + ft.dwLowDateTime;
    // minus 2 hours.
    qwResult -= 2 * _HOUR;
    // Copy the result back into the FILETIME structure.
    ft.dwLowDateTime  = (DWORD) (qwResult & 0xFFFFFFFF );
    ft.dwHighDateTime = (DWORD) (qwResult >> 32 );

    FileTimeToSystemTime(&ft, &sysTime);
} 

 

参考网址:http://support.microsoft.com/kb/188768

你可能感兴趣的:(Microsoft)