Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. detecting IP

detecting IP

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    How to detect the IP of the computer the programm is working on?:-D :rose:

    P B 2 Replies Last reply
    0
    • L Lost User

      How to detect the IP of the computer the programm is working on?:-D :rose:

      P Offline
      P Offline
      Pavlos Touboulidis
      wrote on last edited by
      #2

      From the Winsock Programmer's FAQ:
      http://www.cyberport.com/~tangent/programming/winsock/intermediate.html#getipaddr
      Example:
      http://www.cyberport.com/~tangent/programming/winsock/examples/ipaddr.html

      1 Reply Last reply
      0
      • L Lost User

        How to detect the IP of the computer the programm is working on?:-D :rose:

        B Offline
        B Offline
        BLaZe
        wrote on last edited by
        #3

        void CGetIPDlg::GetIP()
        {
        WORD wVersionRequested;
        WSADATA wsaData;
        char name[255];
        CString ip;
        PHOSTENT hostinfo;
        wVersionRequested = MAKEWORD( 2, 0 );

          if ( WSAStartup( wVersionRequested, &wsaData ) == 0 )
          {
        
                if( gethostname ( name, sizeof(name)) == 0)
                {
                      if((hostinfo = gethostbyname(name)) != NULL)
                      {
                            ip = inet\_ntoa (\*(struct in\_addr \*)\*hostinfo->h\_addr\_list);
                      }
        			  m\_IP.SetWindowText(ip);
        			  UpdateData(FALSE);
                }
                
                WSACleanup( );
          } 
        

        }

        BLaZe

        ICQ # 110244345
        email : mpblaze@iquebec.com

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups