TGC Codebase Backup



Get your internet IP address by IanM

18th Jan 2007 20:05
Summary

Retrieve your internet IP address in string format



Description



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    print getIP$()
wait key
end

function getIP$()
   local IP as string
   local ReadLine as string

   if file exist("temp.dat") then delete file "temp.dat"

   load dll "urlmon.dll", 1
   Status = call dll(1, "URLDownloadToFileA", 0, "http://www.whatismyip.org", "temp.dat", 0, 0)
   delete dll 1

   if Status = 0
      open to read 1, "temp.dat"
      read string 1, IP
      close file 1
   endif

   if IP = "" then IP = "unknown"

   if file exist("temp.dat") then delete file "temp.dat"
endfunction IP