示例#1
0
        private string ConnectDrive(NETRESOURCE1 NetDrive, string UserName, string Password)
        {
            StringBuilder UN = new StringBuilder(UserName);
            StringBuilder PW = new StringBuilder(Password);

            return(WNetAddConnection2(NetDrive, PW, UN, 0).ToString());
        }
示例#2
0
        public string CreateDrive(string LocalName, string RemoteName, string UserName, string Password)
        {
            NETRESOURCE1 NetDrive = new NETRESOURCE1();

            NetDrive.LocalName  = LocalName;
            NetDrive.RemoteName = RemoteName;

            NDList.Add(NetDrive);
            return(ConnectDrive(NetDrive, UserName, Password));
        }
示例#3
0
 private static extern uint WNetAddConnection2([In] NETRESOURCE1 lpNetResource, StringBuilder lpPassword, StringBuilder lpUsername, uint dwFlags);
示例#4
0
        private string DisconnectDrive(NETRESOURCE1 NetDrive)
        {
            string LocalName = NetDrive.LocalName;

            return(WNetCancelConnection2(LocalName, 1, true).ToString());
        }