且看代码:
#include <windows.h> #include <iostream> using namespace std;
int main(int argc, char* argv[]) { LPCTSTR file = "c:/Downloads/1.exe"; DWORD dwSizeLow, dwSizeHigh; HANDLE hFile = ::CreateFile(file, GENERIC_READ, NULL, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if(hFile != INVALID_HANDLE_VALUE) { dwSizeLow = GetFileSize(hFile, &dwSizeHigh); cout << dwSizeLow << endl; cout << dwSizeHigh << endl; } }
|
事实上完全不需要dwSizeHigh, 因为只有文件大小高于32的才会在dwSizeHigh当中存储值,通过计算发现, 2^32 - 1 = 4G, 一般文件哪有这么大啊……
阅读(746) | 评论(0) | 转发(0) |