Ok...here's an idea..
Code:
#include <windows.h>
#include <winnetwk.h> //include mpr.lib with project
#include <iostream>
using namespace std;
int main (void){
HANDLE hNetRes;//Handle to resources
DWORD dwToEnum = 0xFFFFFFFF,//enumerate all
dwSize = 2048,//size of buffer...make larger if needed
dwErr;
LPVOID lpv = NULL;//buffer for info
NETRESOURCE *lpnr = NULL;//allow me to address info as NETRESOURCE
WNetOpenEnum(RESOURCE_CONTEXT,NULL,NULL,
NULL,&hNetRes);//Get Handle
if(!hNetRes){
dwErr = GetLastError();
cout << "Error " << dwErr << " - ";
cout << "Could not begin enum";
return 1;
}
lpv = HeapAlloc(GetProcessHeap(),NULL,dwSize);//Alloc memory
if(lpv == NULL){
dwErr = GetLastError();
cout << "Error " << dwErr << " - ";
cout << "Could not allocate memory";
return 1;
}
lpnr = (NETRESOURCE*)lpv;//sync the pointers...
WNetEnumResource(hNetRes,&dwToEnum,lpv,&dwSize);//Get data
for(int i = 0;i < dwToEnum;i++,lpnr++){
cout << "Found item " << i+1 << " ";
if(lpnr->lpRemoteName != NULL)
cout << lpnr->lpRemoteName << endl;
else
cout << "but no details available" << endl;
}
HeapFree(GetProcessHeap(),NULL,lpv);//Free memory
WNetCloseEnum(hNetRes); //free handle
return 0;
}
It has a wierd bug that returns duff info for the first data block enumerated....that's why I added the "but no details available" thing........might just be my crappy home network which is only used for LAN games......or maybe something else.....couldnt be bothered to hunt the error, so I will leave that to you.