Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than kernel32, prefix the name with the module name and a period.
Declare Function GetVolumePathNamesForVolumeName Lib "kernel32.dll" (TODO) As TODO
VB Signature #2:
'''Return Type: BOOL->int
'''param0: LPCTSTR->LPCWSTR->WCHAR*
'''param1: LPTSTR->LPWSTR->WCHAR*
'''param2: DWORD->unsigned int
'''param3: PDWORD->DWORD*
<DllImportAttribute("kernel32.dll", EntryPoint:="GetVolumePathNamesForVolumeNameW")> _
Public Shared Function GetVolumePathNamesForVolumeNameW(<[In]()> <MarshalAs(UnmanagedType.LPTStr)> ByVal sVolumeName As String, _
<MarshalAs(UnmanagedType.LPWStr)> ByVal sPathNames As System.Text.StringBuilder, _
ByVal uintBufferLen As UInteger, <Out()> ByRef uintReturnLen As UInteger) _
As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
Using StringBuilder for the buffer does not work since this function returns the names as a bunch of strings separated by the null character ('\0'). So StringBuilder would only report the first item. Therefore we store it in a char array, which can later be converted to a bunch of strings.
Tips & Tricks:
Please add some!
Sample Code:
UInt32 dwRequired = 0;
char[] buffer = new char[260];
if (!GetVolumePathNamesForVolumeName(volumeName, buffer, (uint)buffer.Length, ref dwRequired))
{
// Not enough room in buffer perhaps? Try a bigger one
buffer = new char[dwRequired];
if (!GetVolumePathNamesForVolumeName(volumeName, buffer, (uint)buffer.Length, ref dwRequired))
throw new Win32Exception();
}
Sample Code 2:
public List<string> GetMountPointsForVolume(string volumeDeviceName)
{
List<string> result = new List<string>();
// GetVolumePathNamesForVolumeName is only available on Windows XP/2003 and above
int osVersionMajor = Environment.OSVersion.Version.Major;
int osVersionMinor = Environment.OSVersion.Version.Minor;
if (osVersionMajor < 5 || (osVersionMajor == 5 && osVersionMinor < 1))
{
return result;
}
if (!GetVolumePathNamesForVolumeNameW(volumeDeviceName, buffer, lpcchReturnLength, ref lpcchReturnLength))
{
throw new Win32Exception(Marshal.GetLastWin32Error());
}
string[] mounts = buffer.Split('\0');
foreach (string mount in mounts)
{
if (mount.Length > 0)
{
result.Add(mount);
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
return result;
}
Click to read this page
10/2/2011 2:35:57 AM - txzhgh-89.110.151.174
Click to read this page
10/2/2011 2:35:57 AM - txzhgh-89.110.151.174
Click to read this page
10/2/2011 2:35:57 AM - txzhgh-89.110.151.174
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).