?GetPublicIpAddress() ******************************************************************************** Function GetPublicIpAddress() ******************************************************************************** *!* Returns public IP address *!* Works under all conditions, routers, proxies, etc. *!* Works in all Windows versions from 95 to Vista *!* Downloads a file from a public HTTP server #Define ERROR_SUCCESS 0 Local; m.lcUrl As String, ; m.lcFile As String, ; m.lcIP As String *!* Generate a random Temp file name: m.lcFile = Addbs(Sys(2023)) + Sys(3) *!* Add fake parameter to avoid web caching: m.lcUrl = "http://checkip.dyndns.org" + "?" + Sys(3) *!* Set default value to return if API call fails: m.lcIP = "0.0.0.0" *!* Attemp to download file: If apiURLDownloadToFile(0, m.lcUrl, m.lcFile, 0, 0) = ERROR_SUCCESS Then *!* Check if file was created: If File(m.lcFile) Then *!* Extract IP from file: m.lcIP = Substr(Filetostr(m.lcFile), 77) m.lcIP = Left(m.lcIP, Len(m.lcIP) - 16) Delete File (m.lcFile) Endif Endif Return m.lcIP Endfunc ******************************************************************************** Function apiURLDownloadToFile(m.pCaller, m.szURL, m.szFileName, m.dwReserved, m.lpfnCB) ******************************************************************************** Declare Integer URLDownloadToFile In urlmon.Dll As apiURLDownloadToFile; Integer pCaller, ; String szURL, ; String szFileName, ; Integer dwReserved, ; Integer lpfnCB Return apiURLDownloadToFile(m.pCaller, m.szURL, m.szFileName, m.dwReserved, m.lpfnCB) Endfunc