gpt4 book ai didi

c++ - CString 值在 64 位转换期间被截断

转载 作者:行者123 更新时间:2023-11-27 23:56:33 27 4
gpt4 key购买 nike

当我从 Ulong64 转换为 cstring 时,值在 64 位中被截断,有人可以帮我解决这个问题吗?

HMONITOR hmonitor64;  // Hmonitor decl  
hmonitor64 = (HMONITOR)0x0000000300290eaf;// initialize to big value
ULONG64 lmonitor64;
CString strMonitor64;
lmonitor64 = (ULONG64)hmonitor64; // typecasted to long
strMonitor64.Format(_T("%lu"), lmonitor64); // value gets truncated in cstring

最佳答案

格式化 ULONG64 的正确方法如下:

HMONITOR hmonitor64;  // Hmonitor decl  
hmonitor64 = (HMONITOR)0x0000000300290eaf;// initialize to big value
ULONG64 lmonitor64;
CString strMonitor64;
lmonitor64 = (ULONG64)hmonitor64; // typecasted to long
strMonitor64.Format(_T("%I64u"), lmonitor64); // value gets truncated in cstring

关于c++ - CString 值在 64 位转换期间被截断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42269227/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com