What is the proper way to convert a FILETIME
structure into __int64
? Can you please tell me?
you can try the code follow. the code is from chromium project
template
inline Dest bit_cast(const Source& source) {
Dest dest;
memcpy(&dest, &source, sizeof(dest));
return dest;
}
//FILETIME to __int64
__int64 FileTimeToMicroseconds(const FILETIME& ft) {
return bit_cast<__int64, FILETIME>(ft) / 10;
}
void MicrosecondsToFileTime(__int64 us, FILETIME* ft) {
*ft = bit_cast(us * 10);
}
int _tmain(int argc, _TCHAR* argv[])
{
__int64 nTmpUint64 = 13060762249644841;
time_t unixtime;
FILETIME nTmpFileTm;
MicrosecondsToFileTime(nTmpUint64,&nTmpFileTm);
return 0;
}