You, excuse me, I am using win32 API to delete the partition, is read the MBR, the result error: when reading the MBR GetLastError 87 parameters are incorrect, check the parameters, didn't find what's the problem, the code is as follows:
TCHAR diskPath [DISK_PATH_LEN];
Swprintf_s (diskPath, _T (" \ \ \ \. \ \ PhysicalDrive % d "), Disk).
HANDLE hDevice=CreateFile (
DiskPath, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,//the default security attributes
OPEN_EXISTING,//disposition
0,//the file attributes
NULL);
DWORD dwByteRead;
BYTE buf [512].
Memset (buf, 0, 512);
if (! ReadFile (hDevice, buf, 512, & amp; DwByteRead, NULL))
{
AfxMessageBox (_T (" ReadFile MBR Error: % ld \ n "), GetLastError ());//GetLastError 87: parameter wrong
return -1;
}
You excuse me, where is this code is wrong, why always quote GetLastError () - 87?????? I checked on the net, relevant solutions,
1. In setting the CreateFile FILE_FLAG_OVERLAPPED, ReadFile when the OVERLAPPED set to NULL,
2. The CreateFile not set FILE_SHARE_WRITE,
3. ReadFile, buf should be the size of the storage media sector integer times,
These cases are tried, is still the GetLastError () - 87? Still hope you give some advice, I appreciate!!!!!!