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. Getting IP Address from IP Control

Getting IP Address from IP Control

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
4 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.
  • P Offline
    P Offline
    pandit84
    wrote on last edited by
    #1

    Hi , I am trying to get IP Address from an IP Control using below code. But I am getting an IP Address in Reverse Order , like if my IP Contrl has 123.45.67.89 , then inet_ntoa () method return address as 89.67.45.123. Can you provide any information on how to get IP Address from IP Control.

    DWORD dwIPAddress ;
    ::SendMessage (hwndIPAddress,IPM_GETADDRESS,0, (LPARAM) (LPDWORD) &dwIPAddress ) ;
    struct in_addr addr;
    addr.S_un .S_addr = (ULONG)dwIPAddress ;
    char *IPAddres = new char[9] ;
    IPAddres = inet_ntoa (addr) ;

    _ S 2 Replies Last reply
    0
    • P pandit84

      Hi , I am trying to get IP Address from an IP Control using below code. But I am getting an IP Address in Reverse Order , like if my IP Contrl has 123.45.67.89 , then inet_ntoa () method return address as 89.67.45.123. Can you provide any information on how to get IP Address from IP Control.

      DWORD dwIPAddress ;
      ::SendMessage (hwndIPAddress,IPM_GETADDRESS,0, (LPARAM) (LPDWORD) &dwIPAddress ) ;
      struct in_addr addr;
      addr.S_un .S_addr = (ULONG)dwIPAddress ;
      char *IPAddres = new char[9] ;
      IPAddres = inet_ntoa (addr) ;

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      DWORD dwIPAddress = 0;
      ::SendMessage (hwndIPAddress, IPM_GETADDRESS, 0, (LPARAM)&dwIPAddress);
      struct in_addr addr;
      addr.S_un.S_addr = (ULONG)dwIPAddress ;
      char IPAddress[16] ;
      sprintf(IPAddress, "%d.%d.%d.%d", addr.S_un.s_b1, addr.S_un.s_b2, addr.S_un.s_b3, addr.S_un.s_b4);

      «_Superman_»  _I love work. It gives me something to do between weekends.

      _Microsoft MVP (Visual C++)

      Polymorphism in C

      P 1 Reply Last reply
      0
      • _ _Superman_

        DWORD dwIPAddress = 0;
        ::SendMessage (hwndIPAddress, IPM_GETADDRESS, 0, (LPARAM)&dwIPAddress);
        struct in_addr addr;
        addr.S_un.S_addr = (ULONG)dwIPAddress ;
        char IPAddress[16] ;
        sprintf(IPAddress, "%d.%d.%d.%d", addr.S_un.s_b1, addr.S_un.s_b2, addr.S_un.s_b3, addr.S_un.s_b4);

        «_Superman_»  _I love work. It gives me something to do between weekends.

        _Microsoft MVP (Visual C++)

        Polymorphism in C

        P Offline
        P Offline
        pandit84
        wrote on last edited by
        #3

        Thanks you suparman....:thumbsup:

        1 Reply Last reply
        0
        • P pandit84

          Hi , I am trying to get IP Address from an IP Control using below code. But I am getting an IP Address in Reverse Order , like if my IP Contrl has 123.45.67.89 , then inet_ntoa () method return address as 89.67.45.123. Can you provide any information on how to get IP Address from IP Control.

          DWORD dwIPAddress ;
          ::SendMessage (hwndIPAddress,IPM_GETADDRESS,0, (LPARAM) (LPDWORD) &dwIPAddress ) ;
          struct in_addr addr;
          addr.S_un .S_addr = (ULONG)dwIPAddress ;
          char *IPAddres = new char[9] ;
          IPAddres = inet_ntoa (addr) ;

          S Offline
          S Offline
          Software_Developer
          wrote on last edited by
          #4

          htonl() converts an IPv4 address in host byte order (e.g. mac or pc format) to the IPv4 address in network byte order. inet_ntoa() converts an (Ipv4) Internet network address into an ASCII string.

          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