#include once "window9.bi"

Function GetIpAddress Alias "GetIpAddress" (ByVal gadget As integer) As string Export
  Dim ukaz As Integer
  Dim  As String ss1,ss2,ss3,ss4
  SendMessage(GadgetID(gadget),IPM_GETADDRESS,0,Cast(LPARAm,@ukaz))
  ss4=Hex(ukaz)
  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="&h" & 0 & 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
  Return ss1 & ss2 & ss3 & ss4
End Function
