Loading ...
Sorry, an error occurred while loading the content.
 

Re: get ip address

Expand Messages
  • stefanhes
    Yes Mike, this works, thank you: code-start global true,false false=0 true=1 [updatecheck]
    Message 1 of 24 , Nov 3, 2010
      Yes Mike, this works, thank you:


      'code-start

      global true,false
      false=0
      true=1

      [updatecheck]
      filetitel$="http://www.networksecuritytoolkit.org/nst/cgi-bin/ip.cgi"
      u$ = MultiByteToWideChar$(filetitel$)
      if u$ = "" _
      then
      notice "Warning"+chr$(13)+"No internet?"
      else
      result = ValidURL(u$)
      if result = 0 _
      then
      downloadresult = DownloadToFile(filetitel$, "temp.txt")
      if downloadresult <> 0 _
      then
      notice "Warning"+chr$(13)+"No internet?"
      else
      open "temp.txt" for input as #f
      tekst$ = input$(#f, LOF(#f))
      print tekst$
      close #f
      end if
      else
      notice "Warning"+chr$(13)+"No internet?"
      end if
      end if
      wait



      function MultiByteToWideChar$(String$)
      'converts any string into unicode
      CodePage = 0 : dwFlags = 0
      cchMultiByte = -1
      lpMultiByteStr$ = String$
      cchWideChar = len(String$) * 3
      lpWideCharStr$ = space$(cchWideChar)

      calldll #kernel32, "MultiByteToWideChar", _
      CodePage as ulong, _ 'CP_ACP=0, ansi code page
      dwFlags as ulong, _ 'use 0, flags for character translation
      lpMultiByteStr$ as ptr,_'the ascii string to convert
      cchMultiByte as long, _ 'len of string, -1 for null-terminated string
      lpWideCharStr$ as ptr, _'buffer for returned ansi string
      cchWideChar as long, _ 'size in wide characters of string buffer
      result as long 'returns number of wide characters written to buffer

      if result = 0 then
      MultiByteToWideChar$ = ""
      else
      MultiByteToWideChar$ = left$(lpWideCharStr$, result * 2)
      end if
      end function


      Function DownloadToFile(urlfile$, localfile$)
      open "URLmon" for dll as #url
      calldll #url, "URLDownloadToFileA",_
      0 as long,_ 'null
      urlfile$ as ptr,_ 'url to download
      localfile$ as ptr,_ 'save file name
      0 as long,_ 'reserved, must be 0
      0 as long,_ 'callback address, can be 0
      DownloadToFile as ulong '0=success
      close #url
      end function



      Function ValidURL(urlfile$)
      open "URLmon" for dll as #url
      calldll #url, "IsValidURL",_
      0 as long,_ 'ignored, must be 0
      urlfile$ as ptr,_ 'urlfile to check
      0 as ulong,_ 'ignored, must be 0
      ValidURL as long
      close #url
      end function

      'code-end
    • Stefan Pendl
      ... The code cycles through the list of available IP-addresses and prints out those it finds. What kind of device do you use to connect to the Internet? For a
      Message 2 of 24 , Nov 4, 2010
        >
        > Hi Stefan,
        >
        > Not a bit better. Still only this:
        >
        > 192.168.1.34
        >
        >
        > But where in your code is the second 'print ...'?
        >

        The code cycles through the list of available IP-addresses and prints out those it finds.

        What kind of device do you use to connect to the Internet?

        For a router, you will not get the external address, since it is only known by the router.

        I get the IP-address of my thumb-drive modem, since it is directly connected to the system.

        ---
        Stefan Pendl
        http://stefanpendl.runbasichosting.com/

        Liberty BASIC 4.04 Pro ... http://www.libertybasic.com/assist.html
        Liberty BASIC 4.04 ....... http://www.libertybasic.com/lb404setup.exe

        Liberty BASIC Bug Tracker ... http://libertybasicbugs.wikispaces.com/

        Books at http://www.lulu.com/ and http://www.amazon.com/
        Alyce Watson ... APIs for Liberty BASIC
        Carl Gundel .... Beginning Programming with Liberty BASIC

        Windows 7 Home Premium 64-bit RTM
        AMD Turion X2 RM-70 2GHz, 4GB RAM
      • stefanhes
        I use a ZyXEL prestige 2000 (modem/router, adsl)
        Message 3 of 24 , Nov 4, 2010
          I use a ZyXEL prestige 2000 (modem/router, adsl)

          --- In libertybasic@yahoogroups.com, "Stefan Pendl" <pendl2megabit@...> wrote:
          >
          > >
          > > Hi Stefan,
          > >
          > > Not a bit better. Still only this:
          > >
          > > 192.168.1.34
          > >
          > >
          > > But where in your code is the second 'print ...'?
          > >
          >
          > The code cycles through the list of available IP-addresses and prints out those it finds.
          >
          > What kind of device do you use to connect to the Internet?
          >
          > For a router, you will not get the external address, since it is only known by the router.
          >
          > I get the IP-address of my thumb-drive modem, since it is directly connected to the system.
          >
          > ---
          > Stefan Pendl
          > http://stefanpendl.runbasichosting.com/
          >
          > Liberty BASIC 4.04 Pro ... http://www.libertybasic.com/assist.html
          > Liberty BASIC 4.04 ....... http://www.libertybasic.com/lb404setup.exe
          >
          > Liberty BASIC Bug Tracker ... http://libertybasicbugs.wikispaces.com/
          >
          > Books at http://www.lulu.com/ and http://www.amazon.com/
          > Alyce Watson ... APIs for Liberty BASIC
          > Carl Gundel .... Beginning Programming with Liberty BASIC
          >
          > Windows 7 Home Premium 64-bit RTM
          > AMD Turion X2 RM-70 2GHz, 4GB RAM
          >
        • Stefan Pendl
          ... According to some Google results this is a WLAN rooter. You are either connected via WLAN or a network cable connection to the rooter. This results in
          Message 4 of 24 , Nov 5, 2010
            >
            > I use a ZyXEL prestige 2000 (modem/router, adsl)
            >

            According to some Google results this is a WLAN rooter.

            You are either connected via WLAN or a network cable connection to the rooter.
            This results in being only able to get the local address, which is the one of the network adapter or the WLAN adapter.

            You can only get the external IP, if the device is directly connected to the system and acts like a network adapter, if it is
            connected to a network adapter, you are not able to retrieve the external IP with the posted example.

            You will have to query a web-service in this case as the other example shows.

            ---
            Stefan Pendl
            http://stefanpendl.runbasichosting.com/

            Liberty BASIC 4.04 Pro ... http://www.libertybasic.com/assist.html
            Liberty BASIC 4.04 ....... http://www.libertybasic.com/lb404setup.exe

            Liberty BASIC Bug Tracker ... http://libertybasicbugs.wikispaces.com/

            Books at http://www.lulu.com/ and http://www.amazon.com/
            Alyce Watson ... APIs for Liberty BASIC
            Carl Gundel .... Beginning Programming with Liberty BASIC

            Windows 7 Home Premium 64-bit RTM
            AMD Turion X2 RM-70 2GHz, 4GB RAM
          • Robert Lawson
            ipconfig | more Stephan? I ve always found that the info from ipconfig/all will suffice for most problems and completes a whole lot quicker :S [Non-text
            Message 5 of 24 , Nov 5, 2010
              ipconfig | more Stephan? I've always found that the info from ipconfig/all
              will suffice for most problems and completes a whole lot quicker :S


              [Non-text portions of this message have been removed]
            • Stefan Pendl
              ... ipconfig /all displays more than the bare minimum of information. ipconfig | more displays the bare minimum stopping after each page, which is useful
              Message 6 of 24 , Nov 5, 2010
                >
                > ipconfig | more Stephan? I've always found that the info from
                > ipconfig/all
                > will suffice for most problems and completes a whole lot quicker :S
                >

                "ipconfig /all" displays more than the bare minimum of information.

                "ipconfig | more" displays the bare minimum stopping after each page, which is useful if you run Vista and above, since there are
                numerous ip4 to ip6 virtual adapters listed and the information you are interested is on page one.

                Notice, that the argument /all is separated from the command ipconfig by a space.

                To get a list of all arguments use "ipconfig /?".

                ---
                Stefan Pendl
                http://stefanpendl.runbasichosting.com/

                Liberty BASIC 4.04 Pro ... http://www.libertybasic.com/assist.html
                Liberty BASIC 4.04 ....... http://www.libertybasic.com/lb404setup.exe

                Liberty BASIC Bug Tracker ... http://libertybasicbugs.wikispaces.com/

                Books at http://www.lulu.com/ and http://www.amazon.com/
                Alyce Watson ... APIs for Liberty BASIC
                Carl Gundel .... Beginning Programming with Liberty BASIC

                Windows 7 Home Premium 64-bit RTM
                AMD Turion X2 RM-70 2GHz, 4GB RAM
              • Robert Lawson
                ipconfig | more displays the bare minimum stopping after each page Ah, I was intrigued, it s just one I ve never come across :S ty :) To get a list of all
                Message 7 of 24 , Nov 5, 2010
                  ""ipconfig | more" displays the bare minimum stopping after each page"

                  Ah, I was intrigued, it's just one I've never come across :S ty :)

                  "To get a list of all arguments use "ipconfig /?"."

                  Like any other dos command you want help with you mean?

                  "Notice, that the argument /all is separated from the command ipconfig by a
                  space."

                  yes, my bad, oddly it's natural when working with the command prompt, always
                  neglected in e-mails and chats :S I'll learn one day that just that space
                  can save a whole lotta typing :)


                  [Non-text portions of this message have been removed]
                • Stefan Pendl
                  ... You use the more command to display a files content page-wise, but you can use it to display the output of any command page-wise too, by using the pipe
                  Message 8 of 24 , Nov 6, 2010
                    >
                    > ""ipconfig | more" displays the bare minimum stopping after each page"
                    >
                    > Ah, I was intrigued, it's just one I've never come across :S ty :)
                    >

                    You use the "more" command to display a files content page-wise, but you can use it to display the output of any command page-wise
                    too, by using the pipe (|).

                    ---
                    Stefan Pendl
                    http://stefanpendl.runbasichosting.com/

                    Liberty BASIC 4.04 Pro ... http://www.libertybasic.com/assist.html
                    Liberty BASIC 4.04 ....... http://www.libertybasic.com/lb404setup.exe

                    Liberty BASIC Bug Tracker ... http://libertybasicbugs.wikispaces.com/

                    Books at http://www.lulu.com/ and http://www.amazon.com/
                    Alyce Watson ... APIs for Liberty BASIC
                    Carl Gundel .... Beginning Programming with Liberty BASIC

                    Windows 7 Home Premium 64-bit RTM
                    AMD Turion X2 RM-70 2GHz, 4GB RAM
                  Your message has been successfully submitted and would be delivered to recipients shortly.