2017-02-16 1 views
0

Ulong64에서 캐스팅하여 cstring 값이 64 비트에서 잘리는 경우이 문제를 해결할 수 있습니까?64 비트 캐스팅 중에 CString 값이 잘림

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 
+0

, 소스 코드를 포맷하십시오. (편집기의 도구 버튼 '{}'을 사용하십시오.) – Scheff

+2

연구를하지 않고'% llu "를 사용해야합니다. 'long'은 64 비트 플랫폼에서도 Windows/VC에서 32 비트를 의미합니다. 그래서,'long long unsigned' 또는'ULONG64'처럼 사용해야합니다. – Scheff

+0

잘림 또한 32 비트 코드에서 발생합니다. 'HMONITOR'는 32 비트 코드에서 32 비트이므로 너는주의하지 않을 것이다. – IInspectable

답변

3

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 
관련 문제