-
-
[求助]读取磁盘OK,读取卷错误
-
发表于:
2010-6-3 11:10
4466
-
很简单的代码,我打开PhysicalDrive1就可以,但打开C:就错误,请问这是为什么?
#include <stdio.h>
#include <windows.h>
#include <winioctl.h>
int main(void)
{
//LPCTSTR lpszDevice = "\\\\.\\PhysicalDrive1";
LPCTSTR lpszDevice = "\\\\.\\C:";
HANDLE hDevice = CreateFile(lpszDevice,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,0,NULL);
if (!hDevice || (hDevice==(HANDLE)-1))
{
printf("Open Device error:0x%x\n",GetLastError());
return -1;
}
DWORD temp;
const int SECTOR_SIZE = 512;
UCHAR buffer[SECTOR_SIZE];
ReadFile(hDevice,buffer,SECTOR_SIZE,&temp,NULL);
CloseHandle(hDevice);
return 0;
}
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课