编写映射驱动器
步骤:新建一窗体form,建立两个框架frame1和frame2?在frame1上建立四个标签、四个text控件和一个按钮,在frame2上建立一个标签、一个text控件和一个按钮。 ??代码如下? ??Option Explicit ??Private Type NETRESOURCE ??dwScope As Long ??dwTy
步骤:新建一窗体form,建立两个框架frame1和frame2?在frame1上建立四个标签、四个text控件和一个按钮,在frame2上建立一个标签、一个text控件和一个按钮。
??代码如下?
??Option Explicit
??Private Type NETRESOURCE
??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 Type
??Const NO_ERROR = 0
??Const CONNECT_UPDATE_PROFILE = &H1
??Const RESOURCETYPE_DISK = &H1
??Const RESOURCETYPE_PRINT = &H2
??Const RESOURCETYPE_ANY = &H0
??Const RESOURCE_CONNECTED = &H1
??Const RESOURCE_REMEMBERED = &H3
??Const RESOURCE_GLOBALNET = &H2
??Const RESOURCEDISPLAYTYPE_DOMAIN = &H1
??Const RESOURCEDISPLAYTYPE_GENERIC = &H0
??Const RESOURCEDISPLAYTYPE_SERVER = &H2
??Const RESOURCEDISPLAYTYPE_SHARE = &H3
??Const RESOURCEUSAGE_CONNECTABLE = &H1
??Const RESOURCEUSAGE_CONTAINER = &H2
??Private Declare Function WNetAddConnection2 Lib “mpr.
WINDOWS/TEMP//flyswat/fsstc/images\\underlineOnClick.gif)';}" onmouseover="window.status = 'Flyswat Link: dll'; for (i = 0; i < this.children.length; i++) {this.children[i].style.backgroundImage='url(C:/WINDOWS/TEMP//flyswat/fsstc/images\\underlineHighlight.gif)';}" style="BACKGROUND-POSITION: left bottom; BACKGROUND-IMAGE: url(C:/WINDOWS/TEMP//flyswat/fsstc/images\\underline.gif); CURSOR: hand; BACKGROUND-REPEAT: repeat-x" onclick="document.URL='flyswat:link(dll,,)', '_self';return false;" onmouseout="window.status='Flyswat NoLink'; window.status = '; for (i = 0; i < this.children.length; i++) {this.children[i].style.backgroundImage='url(C:/WINDOWS/TEMP//flyswat/fsstc/images\\underline.gif)';}">dll” Alias _
??“WNetAddConnection2A” _
???lpNetResource As NETRESOURCE? _
??ByVal lpPassword As String? _
??ByVal lpUserName As String? _
??ByVal dwFlags As Long? As Long
??Private Declare Function WNetCancelConnection2 Lib “mpr.
dll” Alias _
??“WNetCancelConnection2A” _
???ByVal lpName As String? _
??ByVal dwFlags As Long? _
??ByVal fForce As Long? As Long
??Private Sub cmdConnect_Click??
??Dim NetR As NETRESOURCE
??Dim ErrInfo As Long
??NetR.dwScope = RESOURCE_GLOBALNET
??NetR.dwType = RESOURCETYPE_DISK
??NetR.dwDisplayType = RESOURCEDISPLAYTYPE_SHARE
??NetR.dwUsage = RESOURCEUSAGE_CONNECTABLE
??NetR.lpLocalName = Text1?0?.Text
??NetR.lpRemoteName = Text1?1?.Text
??ErrInfo = WNetAddConnection2?NetR? Text1?3?.Text? Text1?2?.Text? CONNECT_UPDATE_PROFILE?
??If ErrInfo = NO_ERROR Then
??MsgBox “Net connection su
clearcase/" target="_blank" >ccessful?”? vbInformation
??Else
??MsgBox “ERROR? ” & Str?ErrInfo? & “ - Net connection unsuccessful?”? _
??vbExclamation
??End If
??End Sub
??Private Sub cmdDisconnect_Click??
??Dim ErrInfo As Long
??Dim strLocalName As String
??strLocalName = Text1?4?.Text
??ErrInfo = WNetCancelConnection2?strLocalName? CONNECT_UPDATE_PROFILE? False?
??If ErrInfo = NO_ERROR Then
??MsgBox “Net disconnection successful?”? vbInformation
??Else
??MsgBox “ERROR? ” & Str?ErrInfo? & “ - Net disconnection unsuccessful?”? _
??vbExclamation
??End If
??End Sub?
原文转自:http://www.ltesting.net
|