救命呀!!发言就给分!各位大哥给我看看这段程序???

lhh lhh 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我想吧局域网中的某一共享文件夹映射到本地,写了如下的代码,老是连不上,请大家给我看看。
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
...全文

相关推荐

评论 8
收藏 已收藏
分享
返回顶部
lhh
VB基础类 7,788 成员 197,583 内容