Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Browse Computers(Terminals) on Network

I am designing a small application which has a browse button, when clicked it should display all the computers(terminals) on a network in a listbox or grid or it should show commondialog from whereI could select a terminal and do further processing. Is there any api call which I could use to get list of all the terminals along with their ipaddresses and name that I could access from my machine ..

Any help or direction would be appreciated..



Thanks in advance...
[495 byte] By [coolsun20] at [2007-11-11 8:33:24]
# 1 Re: Browse Computers(Terminals) on Network
Hi,
try NetDfsEnum(...) and have a look around the netapi32.lib.
Caution: is not supported in all operating systems, iI believe needs to be > NT4

Cheers,

D
drkybelk at 2007-11-11 21:01:10 >
# 2 Re: Browse Computers(Terminals) on Network
Hi,
I'm using the following code to display computers on my office network:
void __fastcall TFormMain::GetNetworkComputors()
{

LPNETRESOURCE lpnr=0;
DWORD dw;
DWORD size;
size=2056;
dw=0xffffffff;
HANDLE lp;
char* mstr;
//enumerating computers in the workgroup (or domain)
if (WNetOpenEnum(RESOURCE_CONTEXT ,RESOURCETYPE_DISK ,0, lpnr ,&lp) == NO_ERROR) {
lpnr=(LPNETRESOURCE)GlobalAlloc(GPTR,size);
WNetEnumResource(lp,&dw, lpnr,&size) ;
for(unsigned int i=1;i<dw;++i) {
mstr=(char*)(((NETRESOURCE)lpnr[i]).lpRemoteName) ;
mstr+=2;//adjust the pointer
if (!AnsiCompareText(mstr,ServerSocket->Socket->LocalHost))
continue;
CheckListBox1->Items->Add(mstr/*((NETRESOURCE)lpnr[i]).lpRemoteName*/); }
GlobalFree((HGLOBAL) lpnr);
WNetCloseEnum(lp);

}
else
ShowError(GetLastError());
}

Note that I'm using TServerSocket VCL class just to remove the name of my local computer from the computers' list. Other then that it is all Win32 API and is supported under Win9x, Win2x and win xp and probably some others
Ivan** at 2007-11-11 21:02:21 >
# 3 Re: Browse Computers(Terminals) on Network
:) :wave: :wave:
coolsun20 at 2007-11-11 21:03:14 >