How do I find which computers are available on a Windows network?
I experimented with IShellFolder, but no success.
Thx in advance
Printable View
How do I find which computers are available on a Windows network?
I experimented with IShellFolder, but no success.
Thx in advance
I should write this down some where, because this is a first and will probably never happen again ;)
Anyways I tried to figure this out once before but only had limited success. In the end I just threaded a ping class and pinged the network looking for vaild IPs. Then tried to resolve the name of the IP. If it couldnt resolve then I assumed it wasnt a computer. I was a good enough answer for what I needed at the time.
But I believe that windows just sends out a NetBIOS broadcast and then resolves the names of those that respond. So if you can figure out how to get NetBIOS working you should be able to figure it out. I did a search on SourceForge.net and found a bunch of source code for NetBios, and Network Browse. Something in there should help going in the right direction.
That's stupid, I can't imagine Explorer being implemented this way.
I'll take a look at the IRemoteComputer interface, maybe that'll take me further.
BTW it's not my first question here, if that's what you're referring to :)
It's about my 8th ;)
I will have to look at the other 8 questions then
No one ever claimed MS was good at networking.
I found this code it MFC :( but it might help
Code:#include "winnetwk.h"
#pragma comment (lib, "mpr")
...
void EnumLocalNetwork(NETRESOURCE *lpnr)
{
HANDLE hEnum;
DWORD cEntries = -1, cbBuffer = 0x4000;
if (::WNetOpenEnum(RESOURCE_GLOBALNET, RESOURCETYPE_ANY, 0, lpnr, &hEnum) == 0) {
if ((lpnr = (LPNETRESOURCE)::GlobalAlloc(GPTR, cbBuffer)) != NULL) {
while (::WNetEnumResource(hEnum, &cEntries, lpnr, &cbBuffer) == 0) {
for (int ctr = 0; ctr < (int)cEntries; ctr++) {
if (lpnr[ctr].dwDisplayType == RESOURCEDISPLAYTYPE_NETWORK ||
lpnr[ctr].dwDisplayType == RESOURCEDISPLAYTYPE_DOMAIN)
EnumLocalNetwork(&lpnr[ctr]);
else {
AfxMessageBox(lpnr[ctr].lpRemoteName);
}
}
cEntries = -1;
cbBuffer = 0x4000;
}
::GlobalFree(lpnr);
}
::WNetCloseEnum(hEnum);
}
}
void CMFDDLGDlg::OnOK()
{
EnumLocalNetwork(NULL);
MessageBox("DONE");
}
Thanks a lot. Will try it out tomorrow.
...Quote:
Originally posted by CornedBee
BTW it's not my first question here, if that's what you're referring to :)
It's about my 8th ;)
Huh huh, even I wuddent get that wrong.Quote:
Originally posted by Technocrat
I will have to look at the other 8 questions then...
:D :thumb: :D
Man some times you guys are too pick :rolleyes:
Arrrgh! Found out I already did it correctly and the error was somewhere else!
No, wait, I didn't...
Ok, got it now. Thanks for that code Tech.
Your welcome
Glad to help you for a change :D
I wrote a custom iterator that iterates over all filesystem roots and network shares, compatible with the boost filesystem library. Only needs a bit of error checking now.