CreateFile打开的分区,怎么获取文件的大小啊

2024-12-19 19:00:39
推荐回答(1个)
回答1:

通过 GetFileSize API 函数获取文件大小;

HANDLE hFile;
DWORD dwFileSize = 0;
char szData[30];

hFile = CreateFile("e:\test1.wav",GENERIC_READ,FILE_SHARE_READ,NULL,
OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);

dwFileSize = GetFileSize(hFile,NULL);

CloseHandle(hFile);

sprintf(szData,"File Size : %d",dwFileSize);

MessageBox(NULL,szData,"FileSize",MB_ICONINFORMATION);