views:

100

answers:

1

Hi.

I am logged in to a workgroup MSHOME and need to access a named list of server pc's on a domain "xxx.local".

I have tried this:

        const int MAX_PREFERRED_LENGTH = -1;
        int SV_TYPE_WORKSTATION = 1;
        int SV_TYPE_SERVER = 2;
        IntPtr buffer = IntPtr.Zero;
        IntPtr tmpBuffer = IntPtr.Zero;
        int entriesRead = 0;
        int totalEntries = 0;
        int resHandle = 0;
        int sizeofINFO = Marshal.SizeOf(typeof(_SERVER_INFO_100));

        int ret = NetServerEnum(null, 100, ref buffer, MAX_PREFERRED_LENGTH,
            out entriesRead, out totalEntries, SV_TYPE_WORKSTATION | SV_TYPE_SERVER,
            "xxx.local", out resHandle);

...but get back a return value 6118(No browser servers found). This also happens when I make "xxx.local" null which should at least return 1 server (my own PC)??

A: 

OK I got it figured it seems:

int ret = NetServerEnum(null, 100, ref buffer, MAX_PREFERRED_LENGTH, out entriesRead, out totalEntries, SV_TYPE_WORKSTATION | SV_TYPE_SERVER, "xxx.local", out resHandle);

... is the correct usage for accessing list of computers on another domain or workgroup. xxx.local as a domain name returned nothing however xxx returned what I needed. You can test with net view /domain:xxx in command prompt as well.

Pierre