Advertisement
1_2002 Windows API Call/ Explanation #104026

Connect To and Disconnect From Network Drive(s)

Being an NT network administrator and software engineer sure has its advantages. Visual Basic 4.0 has afforded me the opportunity to create useful apps that greatly reduce the amount of time it takes to perform those tasks that many of us perform often. This little app simply uses the Windows 32 API (Win95 or NT 4.0 only) to open the network resource browse list. You can map network resources or disconnect from network resources. Enjoy the code! We've been using it for months in several VB apps on our network and it works GREAT!

AI

Resumen de IA: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Código fuente
original-source
Create a Form with 4 command buttons. 
Name the first three buttons: 'Command1' (This will create a Control Array)
Label the first button: 'Connect Drive'
Label the second button: 'Disconnect Drive'
Label the third button: 'End Capture'
Label the fourth button: 'Quit'
Double-Click on one the button labelled "Connect Drive" and enter the following:
Private Sub Command1_Click(Index As Integer) <<== You won't need this line
  Dim x As Long
  If Index = 0 Then  'Connect
    x = WNetConnectionDialog(Me.hwnd, RESOURCETYPE_DISK)
  ElseIf Index = 1 Then 'Disconnect
    x = WNetDisconnectDialog(Me.hwnd, RESOURCETYPE_DISK)
  Else
    End
  End If
End Sub <<== You won't need this line either.
Name the fourth button 'printerbutton'. Double-Click it and enter the following:
Private Sub printerbutton_Click()
  Dim x As Long
  x = WNetDisconnectDialog(Me.hwnd, RESOURCETYPE_PRINT)
End Sub
Run the app and click each of the buttons to see what happens!
Hope you find it useful!
If you're interested in trading VB code tips, email me at: kkeller@1stnet.com
Comentarios originales (3)
Recuperado de Wayback Machine