Skip to main content

 none
Given a volume name how can I found if the partition on which the volume resides is primary partition or logival volume? RRS feed

  • Question

  • Hi,

    I need to find the partition details of a given volume. I need to find if a given volume resides on a primary partition or logical volume?

    My app is C/C++ Win32 app with admin rights and works as windows service.

    Tuesday, October 30, 2012 7:13 PM

All replies

  • There's a GetVolumePathNamesForVolumeName function you can use to find the location of a volume.

    As for the list of partitions and their drive letters, you can find from the WMI class Win32_DiskPartition or read the partition table via IOCTL_DISK_GET_DRIVE_LAYOUT_EX.



    Visual C++ MVP

    Tuesday, October 30, 2012 8:09 PM
    Moderator
  • GetVolumePathNamesForVolumeName  doesn't serve the purpose as it doesnot give if the volume is logical drive etc.

    IOCTL_DISK_GET_DRIVE_LAYOUT_EX => I am using it but still it cannot give info if the volume if primary or logical drive

    My application(it is disk/volume based backup software) handles primary partition differently than logical drives so I need to differentiate it

    Tuesday, October 30, 2012 10:32 PM
  • you can find partition types in DRIVE_LAYOUT_INFORMATION_EX.PartitionEntry[i].Mbr.PartitionType.

    As for the physicial locations of a volume you can use  IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS.



    Visual C++ MVP

    Tuesday, October 30, 2012 10:59 PM
    Moderator
  • you can find partition types in DRIVE_LAYOUT_INFORMATION_EX.PartitionEntry[i].Mbr.PartitionType. =>Yes I can find the partition type there but there is no partition type defined for logical drive

    As for the physical locations of a volume you can use  IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS.=> this gives us no of disks on which volume resides still does not give us info if volume is logical drive or not

    Wednesday, October 31, 2012 1:53 PM
  • I think you can use the WMI class Win32_DiskPartition to solve your requirement, it seems that the Win32 API we founded here cannot give you the info.

    Mike Zhang[MSFT]
    MSDN Community Support | Feedback to us

    Friday, November 2, 2012 7:21 AM
    Moderator