コード例 #1
0
        private void ConnectToShare(string remoteUnc, string username, string password, bool promptUser)
        {
            NetworkShareAccesser.NETRESOURCE lpNetResource = new NetworkShareAccesser.NETRESOURCE
            {
                dwType       = 1,
                lpRemoteName = remoteUnc
            };
            int num;

            if (promptUser)
            {
                num = NetworkShareAccesser.WNetUseConnection(IntPtr.Zero, lpNetResource, "", "", 24, null, null, null);
            }
            else
            {
                num = NetworkShareAccesser.WNetUseConnection(IntPtr.Zero, lpNetResource, password, username, 0, null, null, null);
            }
            if (num != 0)
            {
                this.Result = this.getErrorForNumber(num);
                return;
            }
            this.Result = "";
        }
コード例 #2
0
 private static extern int WNetUseConnection(IntPtr hwndOwner, NetworkShareAccesser.NETRESOURCE lpNetResource, string lpPassword, string lpUserID, int dwFlags, string lpAccessName, string lpBufferSize, string lpResult);