' Copyright (c) 1996 by Desaware Inc. All Rights Reserved
' Part of the Desaware API Class Library
' For further information contact:
' Desaware Inc.
' 1100 E. Hamilton Ave. Suite #4
' Campbell, CA 95008
' (408) 377-4770
' www.desaware.com
Option Explicit
Private Declare Function WNetOpenEnum Lib "mpr.dll" Alias "WNetOpenEnumA" (ByVal dwScope As Long, ByVal dwType As Long, ByVal dwUsage As Long, lpNetResource As NETRESOURCE, lphEnum As Long) As Long
' We need a separate declaration for the null case
Private Declare Function WNetOpenEnumRoot Lib "mpr.dll" Alias "WNetOpenEnumA" (ByVal dwScope As Long, ByVal dwType As Long, ByVal dwUsage As Long, ByVal lpNetResource As Long, lphEnum As Long) As Long
Private Declare Function WNetEnumResource Lib "mpr.dll" Alias "WNetEnumResourceA" (ByVal hEnum As Long, lpcCount As Long, lpBuffer As Byte, lpBufferSize As Long) As Long
Private Declare Function intWNetAddConnection2 Lib "mpr.dll" Alias "WNetAddConnection2A" (lpNetResource As NETRESOURCE, ByVal lpPassWord As String, ByVal lpUserName As String, ByVal dwFlags As Long) As Long
Private Declare Function intWNetAddConnection3 Lib "mpr.dll" Alias "WNetAddConnection3A" (ByVal hwnd As Long, lpNetResource As NETRESOURCE, ByVal lpPassWord As String, ByVal lpUserName As String, ByVal dwFlags As Long) As Long
Private Declare Function intWNetUseConnection Lib "mpr.dll" Alias "WNetUseConnectionA" (ByVal hwnd As Long, lpNetResource As NETRESOURCE, ByVal lpPassWord As String, ByVal lpUserID As String, ByVal dwFlags As Long, ByVal lpAccessName As String, lpBufferSize As Long, lpResult As Long) As Long
Private Declare Function WNetCloseEnum Lib "mpr.dll" (ByVal hEnum As Long) As Long
' Important error values
Private Const ERROR_EXTENDED_ERROR = 1208&
Private Const ERROR_NO_MORE_ITEMS = 259&
Private Const ERROR_MORE_DATA = 234 ' dderror
Private Type NETRESOURCELONG
dwScope As Long
dwType As Long
dwDisplayType As Long
dwUsage As Long
lpLocalName As Long
lpRemoteName As Long
lpComment As Long
lpProvider As Long
End Type
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
' Holds the current copy of the netresource
Private Info As NETRESOURCE
' Set on object that has been initialized to a valid net resource
Private Initialized As Boolean
' Always loaded with last network API error
Public LastError As Long
' Set only if LastError is ERROR_EXTENDED_ERROR (See dwNetwork)
Public LastNetError As New dwNetError
' Local type name on the remote system.
' Set by WNetGetResourceInformation
Public SystemResourceName$
' Set and Retrieve the flag types. Constants are in dwNetConstants
Public Property Get dwScope() As Long
dwScope = Info.dwScope
End Property
Public Property Get dwType() As Long
dwType = Info.dwType
End Property
Public Property Get dwDisplayType() As Long
dwDisplayType = Info.dwDisplayType
End Property
Public Property Get dwUsage() As Long
dwUsage = Info.dwUsage
End Property
' The set values do not verification. Win32 will catch
' errors when the structure is used in an API call.
Public Property Let dwScope(l As Long)
Info.dwScope = l
End Property
Public Property Let dwType(l As Long)
Info.dwType = l
End Property
Public Property Let dwDisplayType(l As Long)
Info.dwDisplayType = l
End Property
Public Property Let dwUsage(l As Long)
Info.dwUsage = l
End Property
' Note how on the next four string retrieval functions, we
' strip the extra null terminator that was added earlier
' If it's empty or null, we just return the empty string