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. How to get my IP address in Win32 [modified]

How to get my IP address in Win32 [modified]

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

    what I need is know the rightmost part of the IP address for example if it's 192.133.14.17 I want to get the 17.

    modified on Thursday, April 24, 2008 11:26 AM

    M CPalliniC D 3 Replies Last reply
    0
    • H Hanan888

      what I need is know the rightmost part of the IP address for example if it's 192.133.14.17 I want to get the 17.

      modified on Thursday, April 24, 2008 11:26 AM

      M Offline
      M Offline
      Maximilien
      wrote on last edited by
      #2

      The "17" is on the right side of the address, not the left part, that's probably why you cannot get it.

      Maximilien Lincourt Your Head A Splode - Strong Bad

      H 1 Reply Last reply
      0
      • M Maximilien

        The "17" is on the right side of the address, not the left part, that's probably why you cannot get it.

        Maximilien Lincourt Your Head A Splode - Strong Bad

        H Offline
        H Offline
        Hanan888
        wrote on last edited by
        #3

        Sorry for the confusion. Too much hours, I guess... :)

        1 Reply Last reply
        0
        • H Hanan888

          what I need is know the rightmost part of the IP address for example if it's 192.133.14.17 I want to get the 17.

          modified on Thursday, April 24, 2008 11:26 AM

          CPalliniC Online
          CPalliniC Online
          CPallini
          wrote on last edited by
          #4

          And what is your difficulty about?

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

          In testa che avete, signor di Ceprano?

          H 1 Reply Last reply
          0
          • CPalliniC CPallini

            And what is your difficulty about?

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
            This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

            H Offline
            H Offline
            Hanan888
            wrote on last edited by
            #5

            finding the function that returns this data.

            CPalliniC 1 Reply Last reply
            0
            • H Hanan888

              finding the function that returns this data.

              CPalliniC Online
              CPalliniC Online
              CPallini
              wrote on last edited by
              #6

              Have you the IP? Is it storead as a string or whatever? i.e. be specific. :)

              If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
              This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

              In testa che avete, signor di Ceprano?

              H 1 Reply Last reply
              0
              • CPalliniC CPallini

                Have you the IP? Is it storead as a string or whatever? i.e. be specific. :)

                If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

                H Offline
                H Offline
                Hanan888
                wrote on last edited by
                #7

                Sorry for all the confusion I've scattered ... :) I just need to know in my Win32 application what is my IP address.

                1 Reply Last reply
                0
                • H Hanan888

                  what I need is know the rightmost part of the IP address for example if it's 192.133.14.17 I want to get the 17.

                  modified on Thursday, April 24, 2008 11:26 AM

                  D Offline
                  D Offline
                  David Crow
                  wrote on last edited by
                  #8

                  One way would be:

                  gethostname();
                  struct hostent *host = gethostbyname();
                  struct in_addr *ptr = (struct in_addr *) host->h_addr_list[0]
                  int octet = ptr->S_un.S_un_b.s_b4;

                  "Love people and use things, not love things and use people." - Unknown

                  "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                  H 1 Reply Last reply
                  0
                  • D David Crow

                    One way would be:

                    gethostname();
                    struct hostent *host = gethostbyname();
                    struct in_addr *ptr = (struct in_addr *) host->h_addr_list[0]
                    int octet = ptr->S_un.S_un_b.s_b4;

                    "Love people and use things, not love things and use people." - Unknown

                    "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                    H Offline
                    H Offline
                    Hanan888
                    wrote on last edited by
                    #9

                    Thank a lot. Don't have time to 'stitch' it now but first thing after the weekend :)

                    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