Is there a .NET way (or any other way) of populating a combo with the names
or IP addresses of all the pc's attached to the current workgroup?
I have seen examples of doing this with a domain.
Russ
Printable View
Is there a .NET way (or any other way) of populating a combo with the names
or IP addresses of all the pc's attached to the current workgroup?
I have seen examples of doing this with a domain.
Russ
It's probably way, way easier to script an existing command line tool and examine its output than to try to write one from scratch. I know, I used to write stuff like that. ;)
No, there isn't any .NET function that I know of that will retrieve lists of servers/workstations; you have to talk to the operating system to do this, using system calls that may vary depending on the operating system. It isn't for the faint of heart.
Check out the NetServerEnum function of the Network API:
ms-help://MS.VSCC/MS.MSDNVS/netmgmt/ntlmapi2_1vl9.htm
If you don't have the Platform SDK then you probably want to go download it, or you can spend quite a bit of time on the online MSDN site looking for the same info.
You will notice the examples are generally (almost always) given in c++. While you can do API programming in VB, I found it easier at the time to use c++ because that's what all the sample code is written in, and back then it seemed very difficult to get type conversions right in VB5. Nowadays it's supposed to be a lot easier.
Good luck.
Thanks for your reply. I'm suprised its that difficult. But i will read up.
Russ
I have no idea if these will help you, but thought I would give you the links anyway.
http://www.c-sharpcorner.com/Code/20...WithWMI2JO.asp
http://www.c-sharpcorner.com/Code/20...sWithWMIJO.asp
http://www.c-sharpcorner.com/3/Reboo...WithWMIJOD.asp
I got those links from this page:
http://www.c-sharpcorner.com/Networking.asp
While WMI is a very useful and powerful interface, it may be that not every server you talk to has it installed (it is an optional package under NT and 98/Me), so be careful about depending on it.
I'm a little confused. These articles and NetServerEnum seem always to be refering to getting workstations etc from daomains. Will this stuff still work if there is no domain? What if its a simple peer to peer workgroup?
Russ
From what I remember of working with the NetServerEnum API call (and it's been a good while so this may not be correct), if you leave the Domain parameter blank it will assume the current domain, or it will work with current workgroup if you are not in a domain. If you specify a workgroup name that will (I think) work also. What the function is actually doing is asking the operating system to ask the target Browser service (NT 3.51 or later) to return a list of machines it knows about.
How the WMI method actually collects its data I have no idea, although it looks like I'd ought to read up on it because it looks a hell of a lot simpler than using the old API calls.