[SOLVED] ping and unicode
Posted: Thu Sep 08, 2016 2:00 pm
I have this code :
It works fine under 5.42 non unicode, but not in 5.42 with unicode neither 5.50.
The problem is the unicode support, but don't see why.
this line is the problem :
without unicode, it returned 0. With unicode, it returns 32 whatever there's ping or not.
Code: Select all
InitNetwork()
Global EchoMessage.s = "MVPing make a Ping Test"
Procedure Ping(valeur)
Protected sIPAddress.s
Protected IPAddress.l
Protected lngResult.l
Repeat
sIPAddress = GetGadgetText(3)
ReplyBuffer.s = Space(SizeOf(ICMP_ECHO_REPLY) + Len(EchoMessage))
hIcmpFile = IcmpCreateFile_()
dwRetVal = IcmpSendEcho_(hIcmpFile, inet_addr_(sIPAddress), @EchoMessage, Len(EchoMessage), #Null, @ReplyBuffer, Len(ReplyBuffer) + SizeOf(ICMP_ECHO_REPLY), 1000)
IcmpCloseHandle_(hFile)
*Echo.ICMP_ECHO_REPLY = @ReplyBuffer
If (*Echo\DataSize) > 0 ; ping ok
SetGadgetColor(3,#PB_Gadget_BackColor,RGB(0,255,0))
Else ; no ping
SetGadgetColor(3,#PB_Gadget_BackColor,RGB(255,0,0))
Delay(1000)
EndIf
ForEver
EndProcedure
If OpenWindow(0, 245, 73, 295, 175, "Wake on Lan", #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered)
StringGadget(3, 100, 10, 190, 20, "192.168.0.8")
EndIf
CreateThread(@ping(),1)
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
The problem is the unicode support, but don't see why.
this line is the problem :
Code: Select all
If (*Echo\DataSize) > 0