Hi,
I call NetServerEnum to query the local master browser for the list of servers connected to the network. This API returns a pointer to a buffer, whose contents I must copy into a structure to display one of its fields. For this, the code snippet I found in a VB-oriented web site uses the classic CopyMemory... but PB/DLL says it's undefined even though it shows up in win32api.inc. I made sure that all the variables are defined. Any idea?
Thx
FF.
--------------------------------
'win32api.inc
DECLARE SUB CopyMemory LIB "KERNEL32.DLL" ALIAS "RtlCopyMemory" (pDestination AS ANY, pSource AS ANY, BYVAL cbLength AS LONG)
'my prog
#INCLUDE "win32api.inc"
FUNCTION GetServers(sDomain AS STRING) AS LONG
'lists all servers of the specified type
'that are visible in a domain.
DIM bufptr AS LONG
DIM dwEntriesread AS LONG
DIM dwTotalentries AS LONG
DIM dwResumehandle AS LONG
DIM se100 AS SERVER_INFO_100
DIM success AS LONG
DIM nStructSize AS LONG
DIM cnt AS LONG
nStructSize = LEN(se100)
success = NetServerEnum(0&, _
100, _
bufptr, _
%MAX_PREFERRED_LENGTH, _
dwEntriesread, _
dwTotalentries, _
%SV_TYPE_ALL, _
0&, _
dwResumehandle) 'if all goes well
IF success = %NERR_SUCCESS AND _
success <> %ERROR_MORE_DATA THEN
FOR cnt = 0 TO dwEntriesread - 1
CopyMemory se100, BYVAL bufptr + (nStructSize * cnt), nStructSize
'List1.AddItem GetPointerToByteStringW(se100.sv100_name)
NEXT
END IF
CALL NetApiBufferFree(bufptr)
GetServers = dwEntriesread
END FUNCTION
------------------
I call NetServerEnum to query the local master browser for the list of servers connected to the network. This API returns a pointer to a buffer, whose contents I must copy into a structure to display one of its fields. For this, the code snippet I found in a VB-oriented web site uses the classic CopyMemory... but PB/DLL says it's undefined even though it shows up in win32api.inc. I made sure that all the variables are defined. Any idea?
Thx
FF.
--------------------------------
'win32api.inc
DECLARE SUB CopyMemory LIB "KERNEL32.DLL" ALIAS "RtlCopyMemory" (pDestination AS ANY, pSource AS ANY, BYVAL cbLength AS LONG)
'my prog
#INCLUDE "win32api.inc"
FUNCTION GetServers(sDomain AS STRING) AS LONG
'lists all servers of the specified type
'that are visible in a domain.
DIM bufptr AS LONG
DIM dwEntriesread AS LONG
DIM dwTotalentries AS LONG
DIM dwResumehandle AS LONG
DIM se100 AS SERVER_INFO_100
DIM success AS LONG
DIM nStructSize AS LONG
DIM cnt AS LONG
nStructSize = LEN(se100)
success = NetServerEnum(0&, _
100, _
bufptr, _
%MAX_PREFERRED_LENGTH, _
dwEntriesread, _
dwTotalentries, _
%SV_TYPE_ALL, _
0&, _
dwResumehandle) 'if all goes well
IF success = %NERR_SUCCESS AND _
success <> %ERROR_MORE_DATA THEN
FOR cnt = 0 TO dwEntriesread - 1
CopyMemory se100, BYVAL bufptr + (nStructSize * cnt), nStructSize
'List1.AddItem GetPointerToByteStringW(se100.sv100_name)
NEXT
END IF
CALL NetApiBufferFree(bufptr)
GetServers = dwEntriesread
END FUNCTION
------------------
Comment