Hello
I am trying to write to a flash stick (usb) directly. That's why I need to open the device as a physical drive. I read that in windows 7 because of protections one must lock the device , dismount it and get rid of the DOS device.
When I tried to do so, I tried to lock the device by
BOOL bRet = DeviceIoControl( hDiskFile, FSCTL_LOCK_VOLUME, NULL,
0, NULL, 0, lpBytesReturned, lpOverlapped );
and succeeded.
When I tried to dismount the device the program stucked.
bRet = DeviceIoControl( (HANDLE) hDiskFile, (DWORD) FSCTL_DISMOUNT_VOLUME, NULL, 0, NULL, 0, nOutBufferSize
lpBytesReturned, &olap );
DWORD dwRes = WaitForSingleObject(olap.hEvent, INFINITE);
GetOverlappedResult(hDiskFile, &(olap), &dwBytesWritten, FALSE);
What did I do wrong?
Thank you
Shadas
I am trying to write to a flash stick (usb) directly. That's why I need to open the device as a physical drive. I read that in windows 7 because of protections one must lock the device , dismount it and get rid of the DOS device.
When I tried to do so, I tried to lock the device by
BOOL bRet = DeviceIoControl( hDiskFile, FSCTL_LOCK_VOLUME, NULL,
0, NULL, 0, lpBytesReturned, lpOverlapped );
and succeeded.
When I tried to dismount the device the program stucked.
bRet = DeviceIoControl( (HANDLE) hDiskFile, (DWORD) FSCTL_DISMOUNT_VOLUME, NULL, 0, NULL, 0, nOutBufferSize
lpBytesReturned, &olap );
DWORD dwRes = WaitForSingleObject(olap.hEvent, INFINITE);
GetOverlappedResult(hDiskFile, &(olap), &dwBytesWritten, FALSE);
What did I do wrong?
Thank you
Shadas