#include once "window9.bi"

Function GetIpAddress(ByVal gadget As Long) As USTRING Export
	Dim iP As Integer
	Dim  As USTRING ss1,ss2,ss3,ss4
	SendMessage(GadgetID(gadget),IPM_GETADDRESS,0,Cast(LPARAm,@iP))
	ss4=Hex(iP)
	If Len(Str(ss4))=8 Then
		ss1="&h" & Mid(ss4,1,2): ss1=Str(ValInt(ss1)) & "."
		ss2="&h" & Mid(ss4,3,2): ss2=Str(ValInt(ss2)) & "."
		ss3="&h" & Mid(ss4,5,2): ss3=Str(ValInt(ss3)) & "."
		ss4="&h" & Mid(ss4,7,2): ss4=Str(ValInt(ss4))
	Else
		ss1="&h0" & Mid(ss4,1,1): ss1=Str(ValInt(ss1)) & "."
		ss2="&h" & Mid(ss4,2,2): ss2=Str(ValInt(ss2)) & "."
		ss3="&h" & Mid(ss4,4,2): ss3=Str(ValInt(ss3)) & "."
		ss4="&h" & Mid(ss4,6,2): ss4=Str(ValInt(ss4))
	End If
	ss1 = ss1 & ss2 & ss3 & ss4
	Return ss1
End Function
