Announcement

Collapse
No announcement yet.

host addr revisited

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    host addr revisited

    Hi all, in the past there's been alot of posts regarding getting the computers IP address (or addresses). For your next challenge , how could I get the subnet mask and default gateway settings for the respective IP addresses?
    For the purpose of this post , I'm using Windows 2000.

    Any help most gratefully received.

    Adrian


    ------------------

    #2
    You could always shell to a cmd.exe and run "ipconfig /all" and screen scrape all the data off, tons of it in there...

    That's the hard way I'm sure...



    ------------------
    Scott
    Scott Turchin
    MCSE, MCP+I
    http://www.tngbbs.com
    ----------------------
    True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

    Comment


      #3
      a search of the bbs for "subnet" gives me http://www.powerbasic.com/support/pb...ad.php?t=24848 - it may do what you want?


      ------------------
      lance
      powerbasic support
      mailto:[email protected][email protected]</a>
      Lance
      mailto:[email protected]

      Comment


        #4
        Scott - yep, thats the hard way !!! Also it'll pop up a black box in the middle of the screen.
        Lance - thanks, I've got the subnet mask but the data it returns doesn't give the gateway but it does look promising.

        Adrian

        ------------------

        Comment


          #5
          At Microsofts MSDN center they give a C program snippet to get (and change ) the default gateway @ http://msdn.microsoft.com/library/de...iphelp_14.asp.
          However to me it seems to want the function 'GetIpForwardTable' which I can't find in wsock32.inc or win32api.inc. Does anyone know how to get this fucntion ?

          Regards
          Adrian

          ------------------

          Comment


            #6
            Hi,
            The GetIpForwardTable funct is found in iphlpapi.dll

            from MSDN :

            GetIpForwardTable
            [This is preliminary documentation and subject to change.]

            The GetIpForwardTable function retrieves the IP routing table.

            DWORD GetIpForwardTable (
            PMIB_IPFORWARDTABLE pIpForwardTable, // buffer for routing table
            PULONG pdwSize, // size of buffer
            BOOL bOrder // sort the table?
            );

            Parameters
            pIpForwardTable
            Pointer to a buffer that, on successful return, contains the IP routing table as a
            MIB_IPFORWARDTABLE structure.
            pdwSize
            Specifies the size of the buffer pointed to by the pIpForwardTable parameter.
            If the buffer is not large enough to hold the returned routing table, the function
            sets this parameter equal to the required buffer size.
            bOrder
            Specifies whether the returned table should be sorted.
            If this parameter is TRUE, the table is sorted by:
            1. Destination address
            2. Protocol that generated the route
            3. Multipath routing policy
            4. Next-hop address
            in that order.

            Return Values
            If the function succeeds, the return value is NO_ERROR.

            If the function fails, use FormatMessage to obtain the message string for the returned error.

            QuickInfo
            Windows NT: Requires version 4.0 SP4 or later.
            Windows: Requires Windows 98 or later.
            Windows CE: Unsupported.
            Header: Declared in iphlpapi.h.
            Import Library: Use iphlpapi.lib.

            See Also
            MIB_IPFORWARDTABLE
            -per


            ------------------

            Comment


              #7
              Thanks Per, now to try and translate that to English (or at least PowerBasic !!)

              Adrian

              ------------------

              Comment


                #8
                And as if by magic, downloaded the latest winapi.zip and there it is !! Thanks PB

                Adrian

                ------------------

                Comment


                  #9
                  Glad to be of service.

                  ------------------
                  Tom Hanlin
                  PowerBASIC Staff

                  Comment

                  Working...
                  X
                  😀
                  🥰
                  🤢
                  😎
                  😡
                  👍
                  👎