#Include once "window9.bi"

Function SetIpAddress Alias "SetIpAddress" (ByVal gadget As integer, IP_ADDRESS As string) As LongInt export
  dim  As String ss1,ss2,ss3,ss4
  Dim pos_ As integer
  Dim posFI_ As Integer
  Dim by As Byte
  pos_=InStr(IP_ADDRESS,".") : ss1=Mid(IP_ADDRESS,1,pos_-1)
  posFI_=InStr(pos_+1,IP_ADDRESS,"."): ss2=Mid(IP_ADDRESS,pos_+1,posFI_-pos_-1)
  Pos_= posFI_
  posFI_=InStr(pos_+1,IP_ADDRESS,"."): ss3=Mid(IP_ADDRESS,pos_+1,posFI_-pos_-1)
  ss4= Mid(IP_ADDRESS,posFI_+1)
  by=val(ss1)
  ss1=str(Hex(by)): If Len(ss1)=1 Then ss1= "0" & ss1
  by=val(ss2)
  ss2=str(Hex(by)): If Len(ss2)=1 Then ss2= "0" & ss2
  by=val(ss3)
  ss3=str(Hex(by)): If Len(ss3)=1 Then ss3= "0" & ss3
  by=val(ss4)
  ss4=str(Hex(by)): If Len(ss4)=1 Then ss4= "0" & ss4
  ss1="&h" & ss1 & ss2 & ss3 & ss4
  Return SendMessage(GadgetID(gadget),IPM_SETADDRESS,0,ValInt(ss1))
End Function
