home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form frmVBNetwork
- Caption = "Connecting To Network Resources"
- ClientHeight = 3600
- ClientLeft = 2280
- ClientTop = 1485
- ClientWidth = 4890
- Height = 4005
- Left = 2220
- LinkTopic = "Form1"
- ScaleHeight = 3600
- ScaleWidth = 4890
- Top = 1140
- Width = 5010
- Begin VB.TextBox txtDrive
- Height = 285
- Left = 2520
- TabIndex = 1
- Text = "txtDrive"
- Top = 960
- Width = 1575
- End
- Begin VB.CommandButton cmdDisconnect
- Caption = "&Disconnect"
- Height = 375
- Left = 2520
- TabIndex = 5
- Top = 3120
- Width = 1215
- End
- Begin VB.CommandButton cmdConnect
- Caption = "&Connect"
- Height = 375
- Left = 1080
- TabIndex = 4
- Top = 3120
- Width = 1215
- End
- Begin VB.DriveListBox Drive1
- Height = 315
- Left = 360
- TabIndex = 3
- Top = 2520
- Width = 4095
- End
- Begin VB.TextBox txtPassWord
- Height = 375
- Left = 360
- TabIndex = 2
- Text = "txtPassWord"
- Top = 1680
- Width = 4095
- End
- Begin VB.TextBox txtNetPath
- Height = 375
- Left = 360
- TabIndex = 0
- Text = "txtNetPath"
- Top = 360
- Width = 4095
- End
- Begin VB.Label lblDrive
- Alignment = 1 'Right Justify
- Caption = "Connect Drive Letter:"
- Height = 255
- Left = 600
- TabIndex = 9
- Top = 960
- Width = 1695
- End
- Begin VB.Label Label3
- Alignment = 2 'Center
- Caption = "Current Connections"
- Height = 255
- Left = 360
- TabIndex = 8
- Top = 2280
- Width = 4095
- End
- Begin VB.Label Label2
- Alignment = 2 'Center
- Caption = "PassWord (If Required)"
- Height = 255
- Left = 360
- TabIndex = 7
- Top = 1440
- Width = 4095
- End
- Begin VB.Label Label1
- Alignment = 2 'Center
- Caption = "Path To Network Resource"
- Height = 255
- Left = 360
- TabIndex = 6
- Top = 120
- Width = 4095
- End
- Attribute VB_Name = "frmVBNetwork"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- Private Sub cmdConnect_Click()
- Dim ServerText As String, PassWordText As String
- Dim DriveLetter As String, UserName As String
- Dim Msg As String
- Dim Succeed As Long
- Dim nrConnect As NETRESOURCE
- nrConnect.lngType = RESOURCETYPE_DISK
- nrConnect.strLocalName = txtDrive
- nrConnect.strRemoteName = UCase$(txtNetPath)
- nrConnect.strProvider = ""
- ServerText = UCase$(txtNetPath)
- PassWordText = txtPassWord
- DriveLetter = txtDrive
- 'Succeed = WNetAddConnection(ServerText, PassWordText, DriveLetter)
- Succeed = WNetAddConnection2(nrConnect, PassWordText, UserName, CONNECT_UPDATE_PROFILE)
- If IsSuccess(Succeed, Msg) = True Then
-
- Drive1.Refresh
- MsgBox Msg, , "Visual Basic Unleashed!"
-
- End If
- End Sub
- Private Sub Command1_Click()
- End Sub
- Private Sub cmdDisconnect_Click()
- Dim DriveLetter As String, Msg As String
- Dim Succeed As Long
- DriveLetter = Mid$(Drive1.Drive, 1, 2)
- 'DriveLetter = txtDrive
- Succeed = WNetCancelConnection(DriveLetter, True)
- If IsSuccess(Succeed, Msg) = True Then
- Drive1.Refresh
- Else
- MsgBox Msg, , "Visual Basic Unleashed!"
- End If
- End Sub
- Private Sub Form_Load()
- txtNetPath = ""
- txtDrive = ""
- txtPassWord = ""
- End Sub
-