public class ConnectSharedFolder
{
public struct NETRESOURCE
{
public int dwScope;
public int dwType;
public int dwDisplayType;
public int dwUsage;
public string lpLocalName;
public string lpRemoteName;
public string lpComment;
public string lpProvider;
}
[DllImport("mpr.dll", CharSet = CharSet.Ansi, EntryPoint = "WNetAddConnection2A", ExactSpelling = true, SetLastError = true)]
public static extern int WNetAddConnection2(ref ConnectSharedFolder.NETRESOURCE lpNetResource, [MarshalAs(UnmanagedType.VBByRefStr)] ref string lpPassword, [MarshalAs(UnmanagedType.VBByRefStr)] ref string lpUserName, int dwFlags);
[DllImport("mpr.dll", CharSet = CharSet.Ansi, EntryPoint = "WNetCancelConnection2A", ExactSpelling = true, SetLastError = true)]
public static extern int WNetCancelConnection2([MarshalAs(UnmanagedType.VBByRefStr)] ref string lpNam
C#代码:映射网络磁盘
最新推荐文章于 2024-05-15 09:08:11 发布