就像DOS下的 net use \\ip "password$" /user:"user$"
在不使用控件的情况下连接到其它计算机

解决方案 »

  1.   


    构建了个P处理  
    shell 运行他
      

  2.   

    用NamedPipeConnectNamedPipe 去翻MSDN文档
      

  3.   

    但客户不希望在程序中使用shell命令
    有没有其它方法,并且连接后可以上传文件
      

  4.   

    NamedPipe的使用不符合项目要求
    有没有其它方法,登陆计算机
      

  5.   

    NetUseAdd/WNetAddConnection2 总可以了吧,还是去翻 MSDN ;)
      

  6.   

    Private Declare Function WNetAddConnection Lib "mpr.dll" Alias "WNetAddConnectionA" (ByVal lpszNetPath As String, ByVal lpszPassword As String, ByVal lpszLocalName As String) As Long
    Private Declare Function WNetCancelConnection Lib "mpr.dll" Alias "WNetCancelConnectionA" (ByVal lpszName As String, ByVal bForce As Long) As Long
    Const WN_SUCCESS = 0 ' The function was successful.
    Const WN_NET_ERROR = 2 ' An error occurred on the network.
    Const WN_BAD_PASSWORD = 6 ' The password was invalid.
    Function AddConnection(MyShareName As String, MyPWD As String, UseLetter As String) As Integer
        On Local Error GoTo AddConnection_Err
        AddConnection = WNetAddConnection(MyShareName, MyPWD, UseLetter)
    AddConnection_End:
        Exit Function
    AddConnection_Err:
        AddConnection = Err
        MsgBox Error$
        Resume AddConnection_End
    End Function
    Function CancelConnection(DriveLetter As String, Force As Integer) As Integer
        On Local Error GoTo CancelConnection_Err
        CancelConnection = WNetCancelConnection(DriveLetter, Force)
    CancelConnection_End:
        Exit Function
    CancelConnection_Err:
        CancelConnection = Err
        MsgBox Error$
        Resume CancelConnection_End
    End Function
    Private Sub Form_Load()
        'KPD-Team 1999
        'URL: http://www.allapi.net/
        'E-Mail: [email protected]    'to add a connection call by:
        variable = AddConnection(<SharePath>, <Password>, <DriveLetter>)
        'To cancel a connection type:
        varible = CancelConnection(<SharePath, <Force>)
    End Sub
      

  7.   

    我用WNetAddConnection2实现了
    Private Const CONNECT_UPDATE_PROFILE = &H1Private Const RESOURCE_CONNECTED As Long = &H1&
    Private Const RESOURCE_GLOBALNET As Long = &H2&
    Private Const RESOURCETYPE_DISK As Long = &H1&
    Private Const RESOURCEDISPLAYTYPE_SHARE& = &H3
    Private Const RESOURCEUSAGE_CONNECTABLE As Long = &H1&Private Declare Function WNetAddConnection2 Lib "mpr.dll" _
    Alias "WNetAddConnection2A" (lpNetResource As NETCONNECT, _
    ByVal lpPassword As String, ByVal lpUserName As String, _
    ByVal dwFlags As Long) As LongPrivate Type NETCONNECT
    dwScope As Long
    dwType As Long
    dwDisplayType As Long
    dwUsage As Long
    lpLocalName As String
    lpRemoteName As String
    lpComment As String
    lpProvider As String
    End TypePrivate Sub Command1_Click()
      Dim NetR As NETCONNECT
      
      NetR.dwType = RESOURCETYPE_DISK
      NetR.lpLocalName = vbNullString
      NetR.lpRemoteName = "\\zhwj"
      NetR.lpProvider = vbNullString
      
      MapDrive = WNetAddConnection2(NetR, "zhangwenjin", "zhwj", 0)
    End Sub