Click here to Skip to main content
15,891,431 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionBrush and Window Color ... Pin
Hadi Rezaee1-Jan-06 4:42
Hadi Rezaee1-Jan-06 4:42 
AnswerRe: Brush and Window Color ... Pin
Hadi Rezaee1-Jan-06 5:12
Hadi Rezaee1-Jan-06 5:12 
GeneralRe: Brush and Window Color ... Pin
John R. Shaw1-Jan-06 9:08
John R. Shaw1-Jan-06 9:08 
QuestionIP Address Pin
mehrdadov1-Jan-06 1:10
mehrdadov1-Jan-06 1:10 
AnswerRe: IP Address Pin
includeh101-Jan-06 1:15
includeh101-Jan-06 1:15 
GeneralRe: IP Address Pin
Prakash Nadar1-Jan-06 4:21
Prakash Nadar1-Jan-06 4:21 
GeneralRe: IP Address Pin
Jörgen Sigvardsson1-Jan-06 10:08
Jörgen Sigvardsson1-Jan-06 10:08 
AnswerRe: IP Address Pin
Gavin Taylor1-Jan-06 6:10
professionalGavin Taylor1-Jan-06 6:10 
The best way to grab a list of all the ip addresses attached to your local system is using the IPHelper[^] library. You'll need to include the IPHlpApi.h and winsock2.h header files, then add iphlpapi.lib and ws2_32.lib to your list of import libraries.

MIB_IPADDRTABLE  *pIPAddrTable = NULL;
DWORD            dwSize = 0;
DWORD            dwRetVal = 0;
	
if (GetIpAddrTable(pIPAddrTable, &dwSize, 0) != ERROR_INSUFFICIENT_BUFFER )
{
	printf( "Error getting buffer size." );
}
else
{
	pIPAddrTable = ( MIB_IPADDRTABLE * ) malloc ( dwSize );
	
	if ( (dwRetVal = GetIpAddrTable( pIPAddrTable, & dwSize, 0 ) ) != NO_ERROR )
	{
		printf("GetIpAddrTable failed.\n");
	}
	
	for( int i = 0; i < pIPAddrTable->dwNumEntries; i ++ )
	{
		in_addr add;
		in_addr subnet;
	
		ZeroMemory( & add, sizeof( in_addr ) );
		ZeroMemory( & subnet, sizeof( in_addr ) );
		add.S_un.S_addr = pIPAddrTable->table[ i ].dwAddr;
		subnet.S_un.S_addr = pIPAddrTable->table[i].dwMask;
	
		printf("IP Address:         %s\n", inet_ntoa( add ) );
		printf("IP Mask:            %s\n\n", inet_ntoa( subnet ) );
	}
	
	free( pIPAddrTable );
}



Gavin Taylor
w: http://www.gavspace.com



-- modified at 12:11 Sunday 1st January, 2006
AnswerRe: IP Address Pin
Jetli Jerry1-Jan-06 18:05
Jetli Jerry1-Jan-06 18:05 
GeneralRe: IP Address Pin
Gavin Taylor2-Jan-06 1:39
professionalGavin Taylor2-Jan-06 1:39 
GeneralRe: IP Address Pin
Jetli Jerry2-Jan-06 3:31
Jetli Jerry2-Jan-06 3:31 
AnswerRe: IP Address Pin
dipuks1-Jan-06 6:19
dipuks1-Jan-06 6:19 
GeneralRe: IP Address Pin
Jörgen Sigvardsson1-Jan-06 10:08
Jörgen Sigvardsson1-Jan-06 10:08 
GeneralRe: IP Address Pin
zpeng1-Jan-06 11:04
zpeng1-Jan-06 11:04 
AnswerRe: IP Address Pin
ThatsAlok1-Jan-06 18:32
ThatsAlok1-Jan-06 18:32 
QuestionHow do I declare global variable? Pin
Toubou31-Dec-05 23:42
Toubou31-Dec-05 23:42 
AnswerRe: How do I declare global variable? Pin
Dominik Reichl1-Jan-06 1:00
Dominik Reichl1-Jan-06 1:00 
GeneralRe: How do I declare global variable? Pin
Toubou1-Jan-06 1:23
Toubou1-Jan-06 1:23 
GeneralRe: How do I declare global variable? Pin
Dominik Reichl1-Jan-06 1:43
Dominik Reichl1-Jan-06 1:43 
GeneralRe: How do I declare global variable? Pin
Toubou1-Jan-06 2:02
Toubou1-Jan-06 2:02 
AnswerRe: How do I declare global variable? Pin
Jörgen Sigvardsson1-Jan-06 10:11
Jörgen Sigvardsson1-Jan-06 10:11 
GeneralRe: How do I declare global variable? Pin
Stephen Hewitt9-Jan-06 2:38
Stephen Hewitt9-Jan-06 2:38 
GeneralRe: How do I declare global variable? Pin
Jörgen Sigvardsson9-Jan-06 3:37
Jörgen Sigvardsson9-Jan-06 3:37 
GeneralRe: How do I declare global variable? Pin
Stephen Hewitt9-Jan-06 11:29
Stephen Hewitt9-Jan-06 11:29 
QuestionHashtables Pin
jblau31-Dec-05 18:10
jblau31-Dec-05 18:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.