|

楼主 |
发表于 2025-3-7 13:51:54
|
显示全部楼层
HANDLE hDevice; // handle to the drive to be examined
BOOL bResult; // results flag
DWORD junk; // discard results
DWORD dwError;
String csVolume;
csVolume = mDiskEmmc;
// Open the volume
hDevice = CreateFile(csVolume.c_str(), // drive to open
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, // share mode
NULL, // default security attributes
OPEN_EXISTING, // disposition
0, // file attributes
NULL); // don't copy any file's attributes
if (hDevice == INVALID_HANDLE_VALUE) // can't open the drive
{
dwError = GetLastError();
return;
}
//Dismount the volume
bResult = DeviceIoControl(
hDevice, // handle to volume
IOCTL_STORAGE_EJECT_MEDIA, //eject USB
NULL, // lpInBuffer
0, // nInBufferSize
NULL, // lpOutBuffer
0, // nOutBufferSize
&junk, // discard count of bytes returned
(LPOVERLAPPED) NULL); // synchronous I/O
if (!bResult) // IOCTL failed
{
dwError = GetLastError();
}
// Close the volume handle
bResult = CloseHandle(hDevice);
if (!bResult)
{
dwError = GetLastError();
}按照你这个开源代码是无法退出u盘模式 |
|