My IP address

While I connect to Internet by Dial-up
modem connection, how can I get my IP
ADDRESS and HostName?
radek_sAsked:
Who is Participating?
 
naveenkohliConnect With a Mentor Commented:
Look at the following example on codeguru..

http://www.codeguru.com/internet/local_hostname.shtml
0
 
NT_ProgrammerCommented:
Here's some code that does exactly that:

      CString m_IPAddress; // holds the numeric dotted address
      CString m_IPName; // holds the computer name.


      char pszname[ 0x40 ];
      ::gethostname( pszname, sizeof( pszname ) );
      hostent* ph = ::gethostbyname( pszname );
      m_IPName = ph->h_name;
      unsigned u = *( (unsigned*) ( ph->h_addr_list[ 0 ] ) );
      m_IPAddress.Format( "%d.%d.%d.%d", ( u ) & 0x000000ff, ( u >> 8 ) & 0x000000ff, ( u >> 16 ) & 0x000000ff, ( u >> 24 ) & 0x000000ff );
0
All Courses

From novice to tech pro — start learning today.