After two days of completion, the gas is dying! Want to read and write disk sector, I have Baidu, it is written like this:
HANDLE hdevice = CreateFile (TEXT ("\\\\.\\physicaldrive1",//Drive, General PHYSICALDRIVE0 is the primary disk, I do not dry, the whole dead, virtual machine and cardGeneric_reaf,//No access to the driveFile_share_read,//share mode,Null//Default security AttributesOpen_existing,//Disposition 0,//file AttributesNULL);//Do not copy file attributes if(Hdevice = = INVALID_HANDLE_VALUE)//cannot open the drive {
MessageBox ("error"); return(FALSE); }
....................... CloseHandle (hdevice);
Others use the CreateFile function to open the device, get the handle returned by the disk, the handle as the parameters of the DeviceIoControl function to the disk sector bar, I can not, die or die, Win7 under. As long as I use Generic_read or generic_write, only the error will pop up. All kinds of Baidu have not found, but the other people's home partition software does run on my computer.
Finally, I finally see, the Generic_read replaced with File_read_attributes after finally can, my handle got, haha ha! Happy!
Windows CreateFile function does not open the disk with Generic_read access mode