Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VC8.0
How to get all the system names in the LAN .. may be inside an office using VC++ MFC. Dialog Based application and how to list the names in the list control...Pls Help Me.. Frown | :(
 
Modification [OP's anwswer]:
I found the solution myself.
m_ListCtrl->InsertColumn(0,_T("Name"),0,130);
	LPSERVER_INFO_101 pBuf = NULL;
	LPSERVER_INFO_101 pTmpBuf;
	DWORD dwLevel = 101;
	DWORD dwPrefMaxLen = MAX_PREFERRED_LENGTH;
	DWORD dwEntriesRead = 0;
	DWORD dwTotalEntries = 0;
	DWORD dwTotalCount = 0;
	DWORD dwServerType = SV_TYPE_ALL; // all servers
	DWORD dwResumeHandle = 0;
	NET_API_STATUS nStatus;
	wchar_t *pszServerName = NULL;
	DWORD i;	//
	pszServerName = L"\\\\cgdomain.com"; // replace it with yours
	nStatus = NetServerEnum(pszServerName,dwLevel,(LPBYTE *) &pBuf,dwPrefMaxLen,&dwEntriesRead,&dwTotalEntries,dwServerType,NULL,&dwResumeHandle);
	if ((nStatus == NERR_Success) || (nStatus == ERROR_MORE_DATA))
	{
		if ((pTmpBuf = pBuf) != NULL)
		{	
			for (i = 0; i < dwEntriesRead; i++)
			{
				if (pTmpBuf == NULL)
				{
					break;
				}
				char szTxt[MAX_PATH]={0};
				::WideCharToMultiByte( CP_ACP, 0,pTmpBuf->sv101_name,-1, szTxt,MAX_PATH, NULL, 0);
				CString strValue,strTemp1,strTemp2;
				strValue=szTxt;
				strTemp1=strValue.GetAt(0);
				strTemp2=strValue;
				strTemp2.Delete(0);
				strTemp2.MakeLower();
				strValue="";
				strValue=strTemp1+strTemp2;				
				m_ListCtrl->InsertItem(i,strValue);
				pTmpBuf++;
				dwTotalCount++;
			}
		}
	} 
	else
		AfxMessageBox(_T("A system error has occurred"));
	if (pBuf != NULL)
		NetApiBufferFree(pBuf);
Posted 5-Jan-11 2:42am
Edited 5-Jan-11 5:42am
v2
Comments
Gokulnath007 at 5-Jan-11 8:28am
   
Anybody there for helping me???

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You need to retrieve the net mask of the system you're app is running on, then the IP address, and then iterate through all the possible IPs send an ICMP packet to each possible IP (based on netmask/IP).
  Permalink  
Comments
Gokulnath007 at 5-Jan-11 7:58am
   
Yeah.. I want to list all the ip addresses (or) the system names inside the Network(LAN) in which my application is running there.. Its like a chat application..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 390
1 Sergey Alexandrovich Kryukov 329
2 BillWoodruff 210
3 Afzaal Ahmad Zeeshan 204
4 CPallini 185
0 OriginalGriff 5,515
1 DamithSL 4,451
2 Maciej Los 3,902
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,175


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 5 Jan 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100