/// <summary>
    /// 打开共享连接
    /// </summary>
    /// <param name="username"></param>
    /// <param name="password"></param>
    /// <param name="remoteName"></param>
    /// <param name="localName"></param>
    /// <returns></returns>
    public static uint WNetAddConnection(string username, string password, string remoteName, 
                                         string localName) {

      NetResource netResource = new NetResource { 
        dwScope = 2,
        dwType = 1,
        dwDisplayType = 3,
        dwUsage = 1,
        lpLocalName = localName,
        lpRemoteName = remoteName,
        lpProvider = null
      };
      
      uint result = WNetAddConnection2(netResource, password, username, 0);
      return result;
    }
    public static uint WNetAddConnection(NetResource netResource, string username,
                                         string password) {

      uint result = WNetAddConnection2(netResource, password, username, 0);
      return result;
    }
 private static extern uint WNetAddConnection2(NetResource lpNetResource, 
                                               string lpPassword, 
                                               string lpUsername, 
                                               uint dwFlags);