Note that there are some explanatory texts on larger screens.

plurals
  1. PODrive Letter vs. DevicePath
    text
    copied!<p>I'm searching about this since last week, almost all links about DriveLetter x DevicePath/Volume/Device ID/whatever are purple for me.</p> <p>I'm developing an application that List some sotorage devices and also HDI/WPD devices using SetupApi functions with these guids GUID_DEVINTERFACE_USB_DEVICE "A5DCBF10-6530-11D2-901F-00C04FB951ED", GUID_DEVINTERFACE_VOLUME "53F5630D-B6BF-11D0-94F2-00A0C91EFB8B".</p> <p>So... I already able to map devices with drive letter. How? With SetupApi result, using DevicePath to get a DiskNumber and PartitionNumber with DeviceIOControl. And it's ok!!! Actually not all. Actually to CDROM drives I can't get it.</p> <p>Here's my code.</p> <pre><code>int bytesReturned = 0; IOCTL.DiskExtents de1 = new IOCTL.DiskExtents(); int numDiskExtents = 0; IntPtr ptrDe1 = Marshal.AllocHGlobal(Marshal.SizeOf(de1)); bool result = IOCTL.DeviceIoControl(FileHandle, IOCTL.IOControlCodes.IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS, IntPtr.Zero, 0, ptrDe1, Marshal.SizeOf(de1), bytesReturned, null); if ((!result)) { Marshal.FreeHGlobal(ptrDe1); //libera a memória alocada. throw new System.ComponentModel.Win32Exception(); //is thrown here } else { de1 = Marshal.PtrToStructure(ptrDe1, typeof(IOCTL.DiskExtents)); Marshal.FreeHGlobal(ptrDe1); return de1.first.DiskNumber; } </code></pre> <p><strong>For all CDROM drive I have, an IncorrectFunction is thrown.</strong></p> <p>For get the FileHandle I use both, Drive Letter (like "\.\D:") and Device Path. And both fail.</p> <p>I don't know if I am doing something wrong, 'cause this work for USB Mass Storage and hard disks.</p> <p>Thanks.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload