SetVolumeMountPoint (kernel32)
Last changed: -198.240.128.75

.
Summary

C# Signature:

[DllImport("kernel32.dll")]
static extern bool SetVolumeMountPoint(string lpszVolumeMountPoint,
   string lpszVolumeName);

User-Defined Types:

None.

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

    StringBuilder sb = new StringBuilder(1024);
    VolumeFunctions.GetVolumeNameForVolumeMountPoint("C:\\", sb, sb.Capacity);
    richTextBox1.Text = sb.ToString() + "Test";
    VolumeFunctions.SetVolumeMountPoint(@"W:\", @"\C:\Test");
    richTextBox1.AppendText(Win32Exception(Marshal.GetLastWin32Error()).ToString());

public class VolumeFunctions
    {

    [DllImport("kernel32", CharSet = CharSet.Auto, SetLastError = true)]
    internal static extern bool GetVolumeNameForVolumeMountPoint(
        string volumeName,
        StringBuilder uniqueVolumeName,
        int uniqueNameBufferCapacity);

    [DllImport("kernel32.dll")]
    internal static extern bool SetVolumeMountPoint(string lpszVolumeMountPoint,
       string lpszVolumeName);

    }

Alternative Managed API:

Do you know one? Please contribute it!

Documentation