我是linux程序员,当时正在将一些Windows代码移植到Linux。
这是我需要移植的Windows代码段。
///////////////////////////////////////////////////////////////////////////////
//
// static DWORD private_GetLongTime(void)
//
// Function returns current time in the c-runtime format of the
// number of milliseconds since midnight, January 1, 1970.
//
///////////////////////////////////////////////////////////////////////////////
//
static DWORD private_GetLongTime(void)
{
SYSTEMTIME SystemTime;
DWORD dwDateTime = 0;
WORD wYear = 1970;
WORD wDays = 0;
INT64 FileTime;
INT64 FileTime2;
INT64 SecondsSince1970;
// read the current time
GetSystemTime(&SystemTime);
SystemTimeToFileTime(&SystemTime,(FILETIME *) &FileTime);
SystemTime.wYear = 1970;
SystemTime.wMonth = 1;
SystemTime.wDay = 1;
SystemTime.wHour = 0;
SystemTime.wMinute = 0;
SystemTime.wSecond = 0;
SystemTime.wMilliseconds = 0;
SystemTimeToFileTime(&SystemTime,(FILETIME *) &FileTime2);
SecondsSince1970 = (INT64) FileTime - (INT64) FileTime2;
dwDateTime = (DWORD ) (SecondsSince1970/ 10000000L);
return dwDateTime;
}
评论说它返回毫秒,但是据我对API的理解,它返回的是秒数。.请确认...
答案 0 :(得分:0)
static DWORD private_GetLongTime(void)
返回秒。