FILETIME到__int64 [英] FILETIME to __int64

查看:784
本文介绍了FILETIME到__int64的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

FILETIME 结构转换为 __ int64 的正确方法是什么?你能告诉我吗?

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

推荐答案

我不认为你会想: FILETIME 结构到 ULARGE_INTEGER * __ int64 * 因为它可能导致64位Windows上的对齐错误。

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."

来源

如果你真的想要的话,会是这样:

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);

但是类似:

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

很糟糕。

这篇关于FILETIME到__int64的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆