/// <summary> /// Get all mount points for a volume. /// </summary> /// <param name="path">Volume Guid Path.</param> /// <returns>An array of strings that represent mount points.</returns> /// <remarks></remarks> public static string[] GetVolumePaths(string path) { string[] GetVolumePathsRet = default; int cc = 1024; int retc = 0; var mm = new MemPtr(); bool r; mm.Alloc(cc); r = NativeDisk.GetVolumePathNamesForVolumeName(path, mm.Handle, cc, ref retc); if (!r) { return(null); } if (retc > 1024) { mm.ReAlloc(retc); r = NativeDisk.GetVolumePathNamesForVolumeName(path, mm, retc, ref retc); } GetVolumePathsRet = mm.GetStringArray(0L); mm.Free(); return(GetVolumePathsRet); }
/// <summary> /// Retrieves the disk geometry of the specified disk. /// </summary> /// <param name="hfile">Handle to a valid, open disk.</param> /// <param name="geo">Receives the disk geometry information.</param> /// <returns></returns> /// <remarks></remarks> public static bool DiskGeometry(IntPtr hfile, ref DISK_GEOMETRY_EX geo) { if (hfile == DevProp.INVALID_HANDLE_VALUE) { return(false); } MemPtr mm = new MemPtr(); uint l = 0U; uint cb = 0U; l = (uint)Marshal.SizeOf <DISK_GEOMETRY_EX>(); mm.Alloc(l); NativeDisk.DeviceIoControl(hfile, NativeDisk.IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, IntPtr.Zero, 0, mm.Handle, l, ref cb, IntPtr.Zero); geo = mm.ToStruct <DISK_GEOMETRY_EX>(); mm.Free(); return(true); }