FILETIME to __int64

后端 未结 6 2090
日久生厌
日久生厌 2021-01-04 10:11

What is the proper way to convert a FILETIME structure into __int64? Can you please tell me?

6条回答
  •  Happy的楠姐
    2021-01-04 10:37

    I don't think you're suppose to: "Do not cast a pointer to a FILETIME structure to either a ULARGE_INTEGER* or __int64* value because it can cause alignment faults on 64-bit Windows."

    Source.

    If you really wanted it would be something like:

    __int64 to_int64(FILETIME ft)
    {
        return static_cast<__int64>(ft.dwHighDateTime) << 32 | ft.dwLowDateTime;
    }
    
    FILETIME ft = // ...
    __int64 t = to_int64(ft);
    

    But something like:

    FILETIME ft = // ...
    __int64 t = *reinterpet_cast<__int64*>(&ft);
    

    Is bad.

提交回复
热议问题