[DllImport("mpr.dll", CharSet=CharSet.Auto)]
public static extern int WNetGetConnection([MarshalAs(UnmanagedType.LPTStr)] string localName, [MarshalAs(UnmanagedType.LPTStr)] StringBuilder remoteName, ref int length);
Declare Function WNetGetConnection Lib "mpr.dll" (TODO) As TODO
None.
localName is the local name for the network resource (drive or printer)
remoteName is a string builder used to return the network name for the resource
length is the current capacity of the StringBuilder
If the call fails because the StringBuilder is not large enough, the call will return a value of 234, and the Length parameter will contain the required size.
Please add some!
// This sample code assumes you currently have a drive mapped to p:
// Find out what remote device a local mapping is to
int rc=0;
// Size for the buffer we will use
int bsize=200;
// Create a new stringbuilder, pre-sized as above
StringBuilder rname = new StringBuilder(bsize);
// Call the function
rc = WNetGetConnection("p:", rname, ref bsize);
Do you know one? Please contribute it!