Click here to Skip to main content
15,920,687 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: still CDib 2 Pin
S Douglas21-Oct-06 21:00
professionalS Douglas21-Oct-06 21:00 
AnswerRe: still CDib 2 Pin
Hamid_RT22-Oct-06 1:40
Hamid_RT22-Oct-06 1:40 
Questionc++ network library Pin
oldbam21-Oct-06 12:08
oldbam21-Oct-06 12:08 
AnswerRe: c++ network library Pin
El Corazon21-Oct-06 12:20
El Corazon21-Oct-06 12:20 
AnswerRe: c++ network library Pin
evilsocket21-Oct-06 12:20
evilsocket21-Oct-06 12:20 
AnswerRe: c++ network library Pin
Sceptic Mole21-Oct-06 23:53
Sceptic Mole21-Oct-06 23:53 
QuestionDetecting Local IP Address Pin
wasife21-Oct-06 8:41
wasife21-Oct-06 8:41 
AnswerRe: Detecting Local IP Address Pin
evilsocket21-Oct-06 12:18
evilsocket21-Oct-06 12:18 
Assuming that you have only one network interface (your eth card) and a loopback interface (127.0.0.1), i think you could try to get the name of the local computer, and then resolve it in an ip address .

<br />
char  szMyComputerName[0xFF] = {0},<br />
      szMyIpAddress[0xFF]    = {0};<br />
DWORD dwSize = 0xFF;<br />
<br />
::GetComputerName(szMyComputerName,&dwSize);<br />


Now all you have to to is to resolve 'szMyComputerName' as you did in your example .

Naturally, if you have more than one network interface (eth card, wireless, etc), you have to enumerate them and then you choose the one you want to work on :


<br />
SOCKET sd = WSASocket(AF_INET, SOCK_DGRAM, 0, 0, 0, 0);<br />
<br />
INTERFACE_INFO InterfaceList[20];<br />
unsigned long  nBytesReturned;<br />
    <br />
WSAIoctl( sd, SIO_GET_INTERFACE_LIST, 0, 0, &InterfaceList, sizeof(InterfaceList), &nBytesReturned, 0, 0); <br />
<br />
for( int i = 0; i < nBytesReturned / sizeof(INTERFACE_INFO); i++ )<br />
{<br />
    printf( "Interface[%d] : %s\n",i, inet_ntoa( ((sockaddr_in *)&(InterfaceList[i].iiAddress))->sin_addr ) )<br />
}<br />


Hope i helped ....Smile | :)
AnswerRe: Detecting Local IP Address Pin
mahw pgm21-Oct-06 12:24
mahw pgm21-Oct-06 12:24 
AnswerRe: Detecting Local IP Address Pin
Mark Salsbery21-Oct-06 15:07
Mark Salsbery21-Oct-06 15:07 
Questionproblem of offsetof with c compiler Pin
EzraYap21-Oct-06 7:44
EzraYap21-Oct-06 7:44 
AnswerRe: problem of offsetof with c compiler Pin
bob1697221-Oct-06 8:16
bob1697221-Oct-06 8:16 
QuestionRe: problem of offsetof with c compiler Pin
David Crow23-Oct-06 4:51
David Crow23-Oct-06 4:51 
QuestionBinary Search Tree Pin
Pimra21-Oct-06 6:02
Pimra21-Oct-06 6:02 
AnswerRe: Binary Search Tree Pin
Sceptic Mole22-Oct-06 1:36
Sceptic Mole22-Oct-06 1:36 
Questionstrcpy_s is the problem? Pin
mikelar1021-Oct-06 4:45
mikelar1021-Oct-06 4:45 
AnswerRe: strcpy_s is the problem? Pin
Bartosz Bien22-Oct-06 3:27
Bartosz Bien22-Oct-06 3:27 
QuestionChange progress bar fore color Pin
Mohammad A Gdeisat21-Oct-06 3:07
Mohammad A Gdeisat21-Oct-06 3:07 
AnswerRe: Change progress bar fore color Pin
Hamid_RT21-Oct-06 9:34
Hamid_RT21-Oct-06 9:34 
GeneralRe: Change progress bar fore color Pin
Mohammad A Gdeisat21-Oct-06 9:48
Mohammad A Gdeisat21-Oct-06 9:48 
GeneralRe: Change progress bar fore color Pin
Hamid_RT22-Oct-06 1:28
Hamid_RT22-Oct-06 1:28 
Question[Message Deleted] Pin
wasife21-Oct-06 1:09
wasife21-Oct-06 1:09 
AnswerRe: Simple Question Pin
Hamid_RT21-Oct-06 1:18
Hamid_RT21-Oct-06 1:18 
GeneralRe: Simple Question Pin
Sceptic Mole21-Oct-06 5:50
Sceptic Mole21-Oct-06 5:50 
AnswerRe: Simple Question Pin
Kiomuto21-Oct-06 5:57
Kiomuto21-Oct-06 5:57 

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.