| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 483 人关注过本帖
标题:谁能帮小弟看下这段代码,运行时老出错
只看楼主 加入收藏
loululin
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2010-4-12
结帖率:0
收藏
 问题点数:0 回复次数:1 
谁能帮小弟看下这段代码,运行时老出错
Private Declare Function WNetAddConnection2 Lib "mpr.dll" Alias "WNetAddConnection2A" (IpNetResource As NETRESOURCE, ByVal IpPassword As String, ByVal IpUserName As String, ByVal dwFlags As Long) As Long
Private Type NETRESOURCE
    dwScope As Long
    dwType As Long
    dwDisplayType As Long
    dwUsage As Long
    pLocalName As Long
    pRemoteName As Long
    pComment As Long
    pProvider As Long
End Type
Private Declare Function WNetCancelConnection2 Lib "mpr.dll" Alias "WNetAddCancel2A" (ByVal IpName As String, ByVal dwFlags As Long, ByVal fForce As Long) As Long

Private Sub Command1_Click() '连接
Dim NR As NETRESOURCE: Dim MyErr As Long
NR.dwScope = RESOURCE_GLOBALNET: NR.dwType = RESOURCETYPE_DISK
NR.dwDisplayType = RESOURCEDISPLAYTYPE_SHADRE
NR.dwUsage = RESOURCEUSAGE_CONNECTABLE
NR.IpLocalName = Text1.Text: NR.IpRemoteName = Text2.Text
MyErr = WNetAddConnection2(NR, Text1.Text, Text2.Text, CONNECT_UPDATE_PROFILE)
If MyErr = NO_ERROR Then
MsgBox "网络驱动器映射成功!", vbInformation, "映射信息提示"
Else
   MsgBox "出现错误:" & Err.Description & "- 网络驱动器映射失败!", vbExclamation, "映射信息提示"
   End If
End Sub

Private Sub Command2_Click() '退出
End
End Sub

Private Sub Command3_Click() '断开
Dim MyErr As Long: Dim strName As String: strName = Text5.Text
MyErr = WNetCancelConnection2(strName, CONNECT_UPDATE_PROFILE, False)
If MyErr = NO_ERROR Then
    MsgBox "成功断开驱动器映射!", vbInformation, "断开信息提示"
Else
    MsgBox "出现错误:" & Err.Description & "- 驱动器断开失败!", vbExclamation, "断开信息提示"
End If
End Sub
搜索更多相关主题的帖子: 代码 运行 
2010-04-15 08:34
bczgvip
Rank: 14Rank: 14Rank: 14Rank: 14
等 级:贵宾
威 望:66
帖 子:1310
专家分:5312
注 册:2009-2-26
收藏
得分:0 
Private Declare Function WNetCancelConnection2 Lib "mpr.dll" Alias "WNetCancelConnection2A" (ByVal lpName As String, ByVal dwFlags As Long, ByVal fForce As Long) As Long
2010-04-15 10:24
快速回复:谁能帮小弟看下这段代码,运行时老出错
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.023974 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved