ULARGE_INTEGER是一个共用体类型:
typedef union _ULARGE_INTEGER {
struct {
DWORD LowPart;
DWORD HighPart;
};
struct {
DWORD LowPart;
DWORD HighPart;
} u;
ULONGLONG QuadPart;
} ULARGE_INTEGER, *PULARGE_INTEGER;
如果编译器支持64位的类型,那么直接用x.QuadPart成员就行了,
如果不支持,就用x.LowPart和x.HighPart来访问(和x.u.LowPart和x.u.HighPart等价)
因此获取磁盘容量时可以不用memcpy,直接输出就行了:
ULARGE_INTEGER FBAT, TNOB, TNOFB;
GetDiskFreeSpaceEx(TEXT("C:\\"), &FBAT, &TNOB, &TNOFB);
cout << "总可用字节数: " << FBAT.QuadPart << endl;
cout << "容量: " << TNOB.QuadPart << endl;
cout << "用户可用字节数: " << TNOFB.QuadPart << endl;