Thread: Network queston for users with mixed OS on their network...

  1. #1
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547

    Network queston for users with mixed OS on their network...

    In windows networking (WNet), the first level of enumeration gets you a list of network providers...

    On my Win7 and XP boxes this is what I get....
    Code:
     Microsoft Terminal Services
     Microsoft Windows Network
     Web Client Network
    Here's the Windows code...

    Code:
    // enumerate lan resources
    #include <windows.h>
    #include <stdio.h>
    
    int _cdecl  main (void)
      { HANDLE hn; 
        PVOID  buf = malloc(1024);
        DWORD idx = 1;
        NETRESOURCE net = {0};
        DWORD  sbuf = 1024;
        WIN32_FIND_DATA fd = {0};
        HANDLE fh;
        CHAR  vn[MAX_PATH];
    
        net.lpRemoteName = "";
    
        if (WNetOpenEnum(RESOURCE_GLOBALNET,RESOURCETYPE_ANY,RESOURCEUSAGE_ALL,&net,&hn))
          { puts("Enum not open");
            return 0; }
    
        while(! WNetEnumResource(hn,&idx,buf,&sbuf))
              printf("%s\n", ((LPNETRESOURCE) buf)->lpRemoteName); 
          
        WNetCloseEnum(hn);
        free(buf);
        puts("");
        return 0; }
    I would be very interested to see what comes back with Windows + Linux, Windows + Mac etc. on the same network...

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    I get the same. I'm sharing a printer off my Mac, and I've got a shared folder so the mac has a \\servername, but I'm not seeing anything extra.

  3. #3
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by tabstop View Post
    I get the same. I'm sharing a printer off my Mac, and I've got a shared folder so the mac has a \\servername, but I'm not seeing anything extra.
    Ok... what I was trying to find out is if I'd end up with "Apple Networking" or something as a provider name...
    Of course the second level (workgroups) also raises the same query...

    Code:
    // enumerate lan resources
    #include <windows.h>
    #include <stdio.h>
    
    int _cdecl  main (void)
      { HANDLE hn; 
        PVOID  buf = malloc(1024);
        DWORD idx = 1;
        NETRESOURCE net = {0};
        DWORD  sbuf = 1024;
        WIN32_FIND_DATA fd = {0};
        HANDLE fh;
        CHAR  vn[MAX_PATH];
    
        net.lpRemoteName = "";
        net.lpProvider = "Microsoft Windows Network";
    
        if (WNetOpenEnum(RESOURCE_GLOBALNET,RESOURCETYPE_ANY,RESOURCEUSAGE_ALL,&net,&hn))
          { puts("Enum not open");
            return 0; }
    
        while(! WNetEnumResource(hn,&idx,buf,&sbuf))
              printf("%s\n", ((LPNETRESOURCE) buf)->lpRemoteName); 
          
        WNetCloseEnum(hn);
        free(buf);
        puts("");
        return 0; }
    Last edited by CommonTater; 09-10-2011 at 09:04 AM. Reason: fixed provider variable

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Code:
    error: 'NETRESOURCE' has no member named 'lpProviderName'
    Fixing that, all I get was WORKGROUP.

  5. #5
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by tabstop View Post
    Code:
    error: 'NETRESOURCE' has no member named 'lpProviderName'
    Fixing that, all I get was WORKGROUP.
    My bad... it's lpProvider ... that'll teach me to rush and not check things...

    Ok so you got workgroup... which is probably the name of your workgroup... on my setup I get ELECTRIC (for the home theatre systems) and PORTABLE (for our wifi devices) ...

    Ok, so far so good... it looks like the Mac is basically indistiguishable from another windows computer, which is just what I was hoping...

    Anyone for Linux? .....

  6. #6
    'Allo, 'Allo, Allo
    Join Date
    Apr 2008
    Posts
    639
    It's the same. They all use either Samba or something which closely mimics it to make use of SMB/CIFS which is MS's protocol for sharing stuff. Probably for compability Samba identifies the computer as a Windows one, not that identifying it as anything else would cause extra entries. The second two names in the list are misnomers, "Microsoft Windows Network" would be better termed as SMB Network, and "Web Client Network" as WebDAV connections.

    You'll probably add more entries to the list if the comp is on an Active Directory or Netware network. Though that's not a guarantee.

  7. #7
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Did you run the code to confirm this ... or are you just saying?

    I know the underpinnings... I'm looking for confirmation from actual testing.
    Unfortunately the Linux box I could test with is currently in Africa with my oldest daughter.

  8. #8

  9. #9
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Thanks tabstop... your answers were very helpful.

    I did manage to get a test with a linux laptop a friend brought over. So it's all good.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Network!
    By Joanna in forum Tech Board
    Replies: 3
    Last Post: 07-20-2004, 06:40 AM
  2. Network Users
    By Traveller in forum Networking/Device Communication
    Replies: 3
    Last Post: 01-20-2004, 03:40 PM
  3. network USB
    By GanglyLamb in forum Tech Board
    Replies: 2
    Last Post: 06-23-2003, 08:42 AM
  4. Finding users on a network and messaging them.
    By Necrodeemer in forum C++ Programming
    Replies: 3
    Last Post: 05-04-2003, 02:04 PM
  5. Network
    By tuarek in forum C++ Programming
    Replies: 2
    Last Post: 09-06-2002, 07:15 AM