//Luigi Bianchi, www.luigibianchi.com        
       
       #include <list> 
       
       typedef list<string> StrList; 
       
       typedef StrList::iterator sl_It;    
       
       bool EnumNet(StrList& list, DWORD dwLevel, LPNETRESOURCE lpNet)
       {
          HANDLE hEnum;
          DWORD dwStatus = WNetOpenEnum(RESOURCE_GLOBALNET, RESOURCETYPE_ANY, 0,        lpNet, &hEnum);
          if (dwStatus != NO_ERROR) return false;
          DWORD dwEntries = 512;
          DWORD dwSize = sizeof(NETRESOURCE) * dwEntries;
          LPNETRESOURCE lpNewNet = new NETRESOURCE[dwEntries];
          dwStatus = WNetEnumResource(hEnum, &dwEntries, (LPVOID)lpNewNet,        &dwSize);
          if (dwStatus != NO_ERROR)
          {
             WNetCloseEnum(hEnum);
             delete [] lpNewNet;
             return false;    
          }
		    WNetCloseEnum(hEnum);    
			 string str; 
          for(int i = 0; i < dwEntries; i++ )
          {  if( lpNewNet[ i ].lpRemoteName )
             {  switch (lpNewNet[ i ].dwDisplayType)
                {  case RESOURCEDISPLAYTYPE_DOMAIN:
                      str = "Domain  ";
                   break;
            		 case RESOURCEDISPLAYTYPE_GENERIC:
                      str = "Generic  ";
                   break;
                   case RESOURCEDISPLAYTYPE_SERVER:
                      str = "Server  ";
                   break;
                   case RESOURCEDISPLAYTYPE_SHARE:
                      str = "Share  ";
                   break;
                   case RESOURCEDISPLAYTYPE_FILE:
                      str = "File  ";
                   break;
                   case RESOURCEDISPLAYTYPE_GROUP:
                      str = "Group  ";
                   break;
                   case RESOURCEDISPLAYTYPE_TREE:
                      str = "Tree  ";
                   break;
       #if(WINVER >= 0x0400)
                   case RESOURCEDISPLAYTYPE_NETWORK:
                      str = "Network  ";
                   break;
                   case RESOURCEDISPLAYTYPE_ROOT:
                      str = "Root  ";
                   break;
                   case RESOURCEDISPLAYTYPE_SHAREADMIN:
                      str = "Share Admin  ";
                   break;
                   case RESOURCEDISPLAYTYPE_DIRECTORY:
                      str = "Directory  ";
                   break;
                   case RESOURCEDISPLAYTYPE_NDSCONTAINER:
                      str = "NDS Container  ";
                   break;
       #endif /* WINVER >= 0x0400 */
                }
                for(int j = 0; j < dwLevel; j++)    //  Indent levels deeper        with spaces
                   str = str + "    ";
                                                      //  Add name and send to        listbox
                str = str + lpNewNet[i].lpRemoteName;
                list.push_back(str);
             }                                           //  Call again for each        entry
             EnumNet(list, dwLevel + 1, lpNewNet + i);
          }
          delete [] lpNewNet;
          return true;
       }
       
       
Copyright (2000), Luigi Bianchi Last Update: September 8, 2000