救命呀!!发言就给分!各位大哥给我看看这段程序???
lhh 2002-01-23 02:43:10 我想吧局域网中的某一共享文件夹映射到本地,写了如下的代码,老是连不上,请大家给我看看。
Public Declare Function WNetAddConnection2 Lib "mpr.dll" Alias "WNetAddConnection2A" (lpNetResource As NETRESOURCE, ByVal lpPassword As String, ByVal lpUserName As String, ByVal dwFlags As Long) As Long
Public Type NETRESOURCE
dwScope As Long
dwType As Long
dwDisplayType As Long
dwUsage As Long
pLocalName As String
pRemoteName As String
pComment As Long
pProvider As Long
End Type
Dim lpnet As NETRESOURCE
lpnet.dwType = 0
lpnet.pLocalName = "G:"
lpnet.pRemoteName = "\\des7\lhh share"
If WNetAddConnection2(lpnet, "lhh", "", 1) <> 0 Then '对方是win98,no username
MsgBox "网络连接错误"
Exit Sub
Else
lstFile.Path = strLocalDriveLetter
'MsgBox ("已经成功映射连接上服务器!")
End If