Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.4 KiB

  1. #include <nt.h>
  2. #include <ntrtl.h>
  3. #include <nturtl.h>
  4. #include <ntioapi.h>
  5. #include <shpriv.h>
  6. HRESULT _GetDriveTypeInfo(HANDLE hDevice, DWORD* pdwDriveType, BOOL* pfFloppy)
  7. {
  8. HRESULT hr;
  9. FILE_FS_DEVICE_INFORMATION ffsdi = {0};
  10. IO_STATUS_BLOCK iosb;
  11. NTSTATUS ntstatus = NtQueryVolumeInformationFile(hDevice, &iosb, &ffsdi,
  12. sizeof(ffsdi), FileFsDeviceInformation);
  13. if (NT_SUCCESS(ntstatus))
  14. {
  15. switch (ffsdi.DeviceType)
  16. {
  17. case FILE_DEVICE_CD_ROM:
  18. case FILE_DEVICE_CD_ROM_FILE_SYSTEM:
  19. case FILE_DEVICE_CHANGER:
  20. *pdwDriveType = HWDTS_CDROM;
  21. break;
  22. case FILE_DEVICE_DISK:
  23. case FILE_DEVICE_DISK_FILE_SYSTEM:
  24. if (FILE_REMOVABLE_MEDIA & ffsdi.Characteristics)
  25. {
  26. *pdwDriveType = HWDTS_REMOVABLEDISK;
  27. if (FILE_FLOPPY_DISKETTE & ffsdi.Characteristics)
  28. {
  29. *pfFloppy = TRUE;
  30. }
  31. }
  32. else
  33. {
  34. *pdwDriveType = HWDTS_FIXEDDISK;
  35. }
  36. break;
  37. default:
  38. // What the hell???
  39. *pdwDriveType = HWDTS_FIXEDDISK;
  40. break;
  41. }
  42. hr = S_OK;
  43. }
  44. else
  45. {
  46. *pdwDriveType = HWDTS_FIXEDDISK;
  47. hr = S_FALSE;
  48. }
  49. return hr;
  50. }