Every day I enter the local network; there are 2 workgroups with more than 20 computers in each. Server works under NT 4.0 and most comuters use Win9x. How can I determine (from Win98, not NT/2k/XP!):
1. What workgroups (or domains) are accesible in current moment?
2. What computers(and other resources) are active in each workgroup?

I have been write a small program based on WNetOpenEnum/ WNetEnumResource but it works NOT properly: results consists zeros and blank strings, see it below:

*************************************************
.386
.model flat, stdcall
option casemap:none

include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
include \masm32\include\masm32.inc
include \masm32\include\mpr.inc

includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\masm32.lib
includelib \masm32\lib\mpr.lib

.data
MsgCaption db "Error code",0
MsgCaption1 db "Net resource",0
MsgCaption2 db "Bytes",0
Msg1 db "All ??", 0
retCode db 16 dup (?)
hEnum dd ?
hMem dd ?
memAvail dd ?
nPoints dd -1
container NETRESOURCE <>
rname db "INFORMATIKA", 0

.code
start:
mov container.dwScope, RESOURCE_CONNECTED
mov container.dwType, RESOURCETYPE_ANY
mov container.dwDisplayType, RESOURCEDISPLAYTYPE_DOMAIN
mov container.dwUsage, RESOURCEUSAGE_CONTAINER
mov container.lpRemoteName, offset rname

invoke GlobalAlloc, GMEM_FIXED OR GMEM_ZEROINIT, 10
mov hMem, eax
invoke WNetOpenEnum,
RESOURCE_CONNECTED, ; scope of enumeration
RESOURCETYPE_ANY, ; resource types to list
RESOURCEUSAGE_CONTAINER,; resource usage to list (0 = ??? ???????)
offset container, ; pointer to resource structure
addr hEnum ; pointer to enumeration handle buffer
invoke WNetEnumResource,
hEnum, ; handle of enumeration
addr nPoints, ; hMem, ; address of buffer for results
addr memAvail ; address of buffer size variable
invoke GlobalFree, hMem
invoke WNetCloseEnum, hEnum

; The second call
invoke GlobalAlloc, GMEM_FIXED OR GMEM_ZEROINIT, memAvail ; ??????? ???? ??????
mov hMem, eax
invoke WNetOpenEnum,
RESOURCE_CONNECTED, ; scope of enumeration
RESOURCETYPE_ANY, ; resource types to list
RESOURCEUSAGE_CONTAINER,; resource usage to list (0 = ??? ???????)
offset container, ; pointer to resource structure
addr hEnum ; pointer to enumeration handle buffer
invoke WNetEnumResource,
hEnum, ; handle of enumeration
addr nPoints,
hMem, ; address of buffer for results
addr memAvail ; address of buffer size variable
.if eax != 0
invoke dwtoa, eax, addr retCode
invoke MessageBox, NULL,addr retCode, addr MsgCaption, MB_OK

.else
invoke dwtoa, memAvail, addr retCode
invoke MessageBox, NULL,addr retCode, addr MsgCaption2, MB_OK
; Size of NETRESOURCE = 32, ???????? lpLocalName=16, lpRemoteName=20
mov esi, hMem
mov ebx, esi
add esi, 20
add ebx, memAvail
.while esi<ebx
invoke MessageBox, NULL, eax, addr MsgCaption1, MB_OK
add esi, 32
.endw
.endif

invoke GlobalFree, hMem
invoke WNetCloseEnum, hEnum

invoke ExitProcess,NULL
end start

*************************************************

Thanks, Mike
Posted on 2001-11-19 05:08:23 by Mike
I haven't tested your code,
but just looking at the first lines, one thing appears to be wrong

When you call WNetOpenEnum you should use RESOURCE_GLOBALNET (instead of RESOURCE_CONNECTED) if you want to use RESOURCEUSAGE_CONTAINER. The dwUsage is ignored if you use any other argument

Random
Posted on 2001-11-22 07:55:18 by random