getvolumenameforvolumemountpoint (kernel32)
Last changed: -174.228.137.208

.
Summary

C# Signature:

[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "GetVolumeNameForVolumeMountPointW")]
static extern bool GetVolumeNameForVolumeMountPoint(string
   lpszVolumeMountPoint, [Out] StringBuilder lpszVolumeName,
   uint cchBufferLength);

User-Defined Types:

None.

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

public static string GetVolumeName(string MountPoint)
{
     const int MaxVolumeNameLength = 100;
     StringBuilder sb = new StringBuilder(MaxVolumeNameLength);
     if (!GetVolumeNameForVolumeMountPoint(MountPoint, sb, (uint) MaxVolumeNameLength))
      Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
     return sb.ToString();
}

Alternative Managed API:

Do you know one? Please contribute it!

Documentation