class twoDword
{
public:
twoDword(){dwl = 0; dwh = 0;}
DWORD dwl;
DWORD dwh;
};
__int64 dwToInt64(DWORD dwl, DWORD dwh)
{
__int64 t64 = 0;
t64 = dwh;
t64 <<= 32;
t64 |= dwl;
return t64;
}
twoDword Int64ToTwoDword_a(__int64 t64)
{
twoDword twd;
twd.dwh = t64 >> 32;
twd.dwl = t64 | 0xFFFFFFFF;
return twd;
}
twoDword Int64ToTwoDword_b(__int64 t64)
{
twoDword twd;
twd.dwh = t64 >> 32;
twd.dwl = (DWORD)t64;
return twd;
}
twoDword Int64ToTwoDword_c(__int64 t64)
{
twoDword twd;
twd.dwh = t64 >> 32;
twd.dwl = t64 | (__int64)0xFFFFFFFF;
return twd;
}
int main()
{
__int64 t64 = 0x388FFFFF388FFFFF;
cout << "the test value : " << t64 << endl << endl;
cout << "__int64 to DWORD + DWORD : " << endl;
twoDword twd;
cout << "Int64ToTwoDword_a : " << endl;
twd = Int64ToTwoDword_a(t64);
cout << "H:" << twd.dwh << " " << "L:" << twd.dwl << endl;
cout << "Int64ToTwoDword_b : " << endl;
twd = Int64ToTwoDword_b(t64);
cout << "H:" << twd.dwh << " " << "L:" << twd.dwl << endl;
cout << "Int64ToTwoDword_c : " << endl;
twd = Int64ToTwoDword_c(t64);
cout << "H:" << twd.dwh << " " << "L:" << twd.dwl << endl;
cout << endl;
cout << "DWORD + DWORD to __int64 : " << endl;
twd.dwh = 0x388FFFFF;
twd.dwl = 0x388FFFFF;
cout << "dwToInt64 : " << endl;
t64 = dwToInt64(twd.dwl, twd.dwh);
cout << "__int64 : " << t64 << endl;
return 0;
}
__int64内存布局,分析即可,按字节