How do I enumerate every machined on a network?

9 views
Skip to first unread message

Kurt Barlar

unread,
Jun 8, 2000, 3:00:00 AM6/8/00
to
I am trying to enumerate every machine on a network, what API calls do I
need?

Thanx!
Kurt

Dubravko Bundalo

unread,
Jun 9, 2000, 3:00:00 AM6/9/00
to
Private Declare Function NetServerEnum Lib "netapi32.dll" ( _
ByVal ServerName As String, _
ByVal level As Long, _
buffer As Long, _
ByVal prefmaxlen As Long, _
entriesread As Long, _
totalentries As Long, _
ByVal servertype As Long, _
ByVal Domain As String, _
resumehandle As Long) As Long

will list all servers
"Kurt Barlar" <kbarlar@@larimore.net> wrote in message
news:1_P%4.17$yU3.2...@news1.i1.net...

SGN Craig

unread,
Jul 11, 2000, 3:00:00 AM7/11/00
to
I am also looking to add this ability to my app. Do you know where I
can find a very simple demo of how this would be used?

THanks

Monte Hansen

unread,
Jul 11, 2000, 3:00:00 AM7/11/00
to
If you can avoid it, forget about the NetServerXxx functions; more work to implement and they have different definitions for NT/98.

Checkout the WNetEnumResources class on my Classes page.

----------------------------------
Monte Hansen
http://KillerVB.com

Please respond to the newsgroups
----------------------------------

"SGN Craig" <c0de3%nospam%@yahoo.com> wrote in message news:396B421C...@yahoo.com...

SGN Craig

unread,
Jul 12, 2000, 3:00:00 AM7/12/00
to
Infact I have. I downloaded your demo. Its very nice, infact its too
nice, it has so many features and abilities that a newbie like me can't
get help from it! I don't understand it. I need a simple howto on
getting a array or a listbox or something like that filled with all the
machines on domain xyz. I can add all the bells a whistles to it
later. Although like I said your demo thing is very nice, its just too
complicated for me to understand. Maybe you could post just the dirt of
getting the machine names. THanks


Craig (The Newbie!)

Monte Hansen

unread,
Jul 13, 2000, 3:00:00 AM7/13/00
to
No problem. Actually, I appreciate that. I sometimes forget how I felt when I was trying to figure this stuff out on my own.

Anyway, I wrote a function that I will add to the WNet module. You can add it manually if you like. It returns an array of computer names:


Public Function GetMachinesForDomain(Optional ByVal DomainName As String) As Variant
'====================================================================================
' GetMachinesForDomain - Returns a list of computers given an optional domain.
'
' DomainName Optional. Name of domain to enumerate. If omitted, uses the
' domain that the local machine participates in, if any.
'
' RETURNS A Variant/String array of computer names.
'
' ERRORS Reflected back to the caller, and thrown.
'====================================================================================

Dim NetResIn As New WNetResource
Dim NetResOut() As WNetResource
Dim nMachines As Long
Dim Machines() As String
Dim i As Long

' Use default domain for local machine if not supplied
If Len(DomainName) = 0 Then
DomainName = GetDomainName()
End If

' Save for input reference
NetResIn.RemoteName = DomainName

' Get NETRESOURCE for the domain
Set NetResIn = GetResourceInfo(NetResIn)

' Get a list of all machines for this domain
nMachines = EnumerateResources(NetResOut, NetResIn, RESOURCE_GLOBALNET)
If nMachines = 0 Then Exit Function

' Size the array to fit
ReDim Machines(1 To nMachines)

' Loop thru each WNetResource
For i = 1 To nMachines

' Store in array that will be retured
Machines(i) = NetResOut(i).RemoteName

Next i

' Return the resulting array
GetMachinesForDomain = Machines

End Function


----------------------------------
Monte Hansen
http://KillerVB.com

Please respond to the newsgroups
----------------------------------

"SGN Craig" <c0de3%nospam%@yahoo.com> wrote in message news:396CCB4C...@yahoo.com...

SGN Craig

unread,
Jul 17, 2000, 3:00:00 AM7/17/00
to
Perfect! Thanks a ton!
Reply all
Reply to author
Forward
0 new messages