Getting your address from the internet isn't always what you want as you may be behind a router and thus it wouldn't be the address you want. There is a way to get a list of useable IP addresses using Winsock, and it can be done in DBP using dll calls.
Now, this code is from a file that I have on my computer. I didn't write it, but uh, credit goes to whoever did.
Functions:
function GetLocalIPCount()
local Count as integer
local p as DWORD
local v as DWORD
local HOSTENT as DWORD
HOSTENT=make memory(256)
Count=0
if GetHostName( HOSTENT, 256 ) = 0
HostInfo=GetHostByName( HOSTENT )
if HostInfo <> 0
p=HostInfo+12
p=*p
do
v=*p
if v = 0 then exit
inc p, 4
inc Count
loop
endif
endif
delete memory HOSTENT
endfunction Count
function GetLocalIP(index as integer)
local ip as string
local p as DWORD
local HOSTENT as DWORD
HOSTENT=make memory(256)
if GetHostName( HOSTENT, 256 ) = 0
HostInfo=GetHostByName( HOSTENT )
if HostInfo <> 0
p=HostInfo+12
p=*p
p=*p
p=p+(index*4)
ip=INET_ntoa( *p )
endif
endif
delete memory HOSTENT
endfunction ip
function GetHostName(memptr as DWORD, size as integer)
local r as integer
local a as DWORD
local s as DWORD
r=call dll(201, "gethostname", memptr, size)
endfunction r
function GetHostByName(memptr as DWORD)
local r as integer
r=call dll(201, "gethostbyname", memptr)
endfunction r
function INET_ntoa(addr as DWORD)
local ip as string
ip=call dll(201, "inet_ntoa", addr)
endfunction ip
function WSAStartup()
local WSADATA as DWORD
local r as integer
local v as WORD
load dll "wsock32.dll",201
WSADATA=make memory(16384)
v=2
r=call dll(201, "WSAStartup", v, WSADATA)
delete memory WSADATA
endfunction r
function WSACleanup()
call dll 201, "WSACleanup"
delete dll 201
endfunction
This is how you use the functions to get your IP address:
if WSAStartup()=0
IP$ = GetLocalIP(0)
WSACleanup()
else
print "Failed to get IP"
endif
I advise however that you do give the user an option to enter their own IP, as in some cases the user might have multiple IP addresses, and this method will not necessarily find the correct one.