Enumerating Servers on Win9x
-
Ok, I understand that the NetServerEnum API functions do not work on a Win9x machine. In VB6, I had code to enumerate Servers on a Windows9x machine, however, porting it to VB.NET seems impossible. I have it working...somewhat. However, it only enumerates the Top-Level Node everytime! If someone could please shed some light on what I am doing wrong I would greatly appreciate it! This was all guess-work on my part even though I understand Marshalling a little bit. Here's what I have so far: 'Declarations 'API Declarations Private Declare Auto Function GlobalAlloc Lib "kernel32" (ByVal wFlags As Integer, ByVal dwBytes As Integer) As Integer Private Declare Auto Function GlobalFree Lib "kernel32" (ByVal hMem As Integer) As Integer 'API Declarations for Win9x Private Declare Ansi Function WNetOpenEnum Lib "mpr.dll" Alias "WNetOpenEnumA" (ByVal dwScope As Integer, ByVal dwType As Integer, ByVal dwUsage As Integer, ByRef lpNetResource As IntPtr, ByRef lphEnum As Integer) As Integer Private Declare Ansi Function WNetEnumResource Lib "mpr.dll" Alias "WNetEnumResourceA" (ByVal hEnum As Integer, ByRef lpcCount As Integer, ByVal lpBuffer As Integer, ByRef lpBufferSize As Integer) As Integer Private Declare Ansi Function WNetCloseEnum Lib "mpr.dll" (ByVal hEnum As Integer) As Integer 'Structures _ Private Structure NETRESOURCE Dim Scope As Integer Dim Type As Integer Dim DisplayType As Integer Dim Usage As Integer Dim LocalName As IntPtr Dim RemoteName As IntPtr Dim Comment As IntPtr Dim Provider As IntPtr End Structure 'Constants for WNetEnum Private Enum ResourceScopes resConnected = &H1 'All currently connected resources (the dwUsage parameter is ignored) resGlobalNet = &H2 'All resources on the network. resRemembered = &H3 'All remembered (persistent) connections (dwUsage is ignored) resRecent = &H4 resContext = &H5 End Enum Private Enum ResourceTypes resAny = &H0 'All resources (this value cannot be combined with RESOURCETYPE_DISK or RESOURCETYPE_PRINT). resDisk = &H1 'All disk resources. resPrinter = &H2 'All print resources. resReserved = &H8 resUnknown = &HFFFF End Enum Private Enum ResourceUseages 'Ignored if the ResourceScope is not 'resGlobalNet' resAll = ((&H1) Or (&H2)) resConnectable = &H1 resC
-
Ok, I understand that the NetServerEnum API functions do not work on a Win9x machine. In VB6, I had code to enumerate Servers on a Windows9x machine, however, porting it to VB.NET seems impossible. I have it working...somewhat. However, it only enumerates the Top-Level Node everytime! If someone could please shed some light on what I am doing wrong I would greatly appreciate it! This was all guess-work on my part even though I understand Marshalling a little bit. Here's what I have so far: 'Declarations 'API Declarations Private Declare Auto Function GlobalAlloc Lib "kernel32" (ByVal wFlags As Integer, ByVal dwBytes As Integer) As Integer Private Declare Auto Function GlobalFree Lib "kernel32" (ByVal hMem As Integer) As Integer 'API Declarations for Win9x Private Declare Ansi Function WNetOpenEnum Lib "mpr.dll" Alias "WNetOpenEnumA" (ByVal dwScope As Integer, ByVal dwType As Integer, ByVal dwUsage As Integer, ByRef lpNetResource As IntPtr, ByRef lphEnum As Integer) As Integer Private Declare Ansi Function WNetEnumResource Lib "mpr.dll" Alias "WNetEnumResourceA" (ByVal hEnum As Integer, ByRef lpcCount As Integer, ByVal lpBuffer As Integer, ByRef lpBufferSize As Integer) As Integer Private Declare Ansi Function WNetCloseEnum Lib "mpr.dll" (ByVal hEnum As Integer) As Integer 'Structures _ Private Structure NETRESOURCE Dim Scope As Integer Dim Type As Integer Dim DisplayType As Integer Dim Usage As Integer Dim LocalName As IntPtr Dim RemoteName As IntPtr Dim Comment As IntPtr Dim Provider As IntPtr End Structure 'Constants for WNetEnum Private Enum ResourceScopes resConnected = &H1 'All currently connected resources (the dwUsage parameter is ignored) resGlobalNet = &H2 'All resources on the network. resRemembered = &H3 'All remembered (persistent) connections (dwUsage is ignored) resRecent = &H4 resContext = &H5 End Enum Private Enum ResourceTypes resAny = &H0 'All resources (this value cannot be combined with RESOURCETYPE_DISK or RESOURCETYPE_PRINT). resDisk = &H1 'All disk resources. resPrinter = &H2 'All print resources. resReserved = &H8 resUnknown = &HFFFF End Enum Private Enum ResourceUseages 'Ignored if the ResourceScope is not 'resGlobalNet' resAll = ((&H1) Or (&H2)) resConnectable = &H1 resC