一.时间类型间的转换:
1.time_t 转 FILETIME
FILETIME ft;
LONGLONG ll = Int32x32To64(t, 10000000) + 116444736000000000;
ft.dwLowDateTime = (DWORD) ll;
ft.dwHighDateTime = (DWORD)(ll >> 32);
2.FILETIME 转 time_t
FILETIME ft;
time_t t;
LONGLONG llTime = ft.dwHighDateTime;
llTime <<= 32;
llTime |= ft.dwLowDateTime;
t = (DWORD)((LONGLONG)(llTime - 116444736000000000) / 10000000);
3.SYSTEMTIME 转 FILETIME
FILETIME ft;
SYSTEMTIME st;
SystemTimeToFileTime( &st, &ft );
4. FILETIME 转 SYSTEMTIME
FILETIME ft;
SYSTEMTIME st;
FileTimeToSystemTime( &ft, &st);
5.DATE 转 SYSTEMTIME
DATE pst;
SYSTEMTIME st;
VariantTimeToSystemTime(pst,&st);
6. SYSTEMTIME 转 DATE
DATE pst;
SYSTEMTIME st;
SystemTimeToVariantTime(st, &pst);
7. BYTE转DWORD
#define MAKEB2W(c0, c1, c2, c3) ((DWORD)(((BYTE)(c0)|((WORD)((BYTE)(c1))<<8))|(((DWORD)(BYTE)(c2))<<16) | (((DWORD)(BYTE)(c3))<<24)))
#### FileTimeToTime_t
####
void FileTimeToTime_t( FILETIME ft, time_t *t )
{
ULARGE_INTEGER ui;
ui.LowPart = ft.dwLowDateTime;
ui.HighPart = ft.dwHighDateTime;
*t = ((LONGLONG)(ui.QuadPart - 116444736000000000) / 10000000);
}
来源:CSDN
作者:hhgo
链接:https://blog.csdn.net/end_ing/article/details/19158511