#include <stdio.h>
#include <windows.h>
#include <winioctl.h>

int main(void)
{
HANDLE hFile = CreateFile("\\\\.\\G:",GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,0,NULL);

DWORD temp;
BOOL bRet = DeviceIoControl(hFile,IOCTL_DISK_IS_WRITABLE,NULL,0,NULL,0,&temp,NULL);

if (!bRet)
{
printf("Error code:%x\n",GetLastError());
}

return 0;
}

相关文章: