Results 1 to 7 of 7

Thread: Get list of PC names on workgroup

  1. #1

    Thread Starter
    New Member russgreen's Avatar
    Join Date
    Apr 2003
    Posts
    12

    Question Get list of PC names on workgroup

    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

  2. #2
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    518
    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.

  3. #3

    Thread Starter
    New Member russgreen's Avatar
    Join Date
    Apr 2003
    Posts
    12
    Thanks for your reply. I'm suprised its that difficult. But i will read up.

    Russ

  4. #4
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464

  5. #5
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    518
    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.

  6. #6

    Thread Starter
    New Member russgreen's Avatar
    Join Date
    Apr 2003
    Posts
    12
    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

  7. #7
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    518
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width