Hi,
i try to ping different host using IcmpSendEcho instead of
System::Call "wininet.dll::InternetCheckConnection(t '192.168.1.1', i ${FLAG_ICC_FORCE_CONNECTION}, i 0) i .r0"
but i doesn't work currently.
Does anybody know why?
I tried used the following code
System::Alloc 1024
Pop $2
#create icmp handle
System::Call 'Iphlpapi::IcmpCreateFile()i.r0'
StrCpy $mIpAddress "192.168.1.250"
System::Call "ws2_32::inet_addr(t "$mIpAddress") l .r1"
#send icmp request
System::Call "Iphlpapi::IcmpSendEcho(i $0,i $1,i 0,i 0,i 0,*t $2,i 512,i 20)i.r3"
StrCmp $3 0 HostNotFound
#host found now parse the cimp echo reply structure
System::Call "*$2(i .r4,i .r5,i .r6,i .r7, i .r8,i .r9)"
DetailPrint "State =$5"
DetailPrint "RoundTripTime =$6"
HostNotFound:
....
So IcmpSendEcho returns $3 =1 but parsing the icmp echo reply structure
leads to $5= and $6=0.
Any Ideas why?
Regards
Mario
NSIS Icmp Ping using IcmpSendEcho
4 posts
The parameter type is not *t.
!include LogicLib.nsh
!define FLAG_ICC_FORCE_CONNECTION 0x00000001
System::Call "wininet::InternetCheckConnection(t 'http://google.com', i ${FLAG_ICC_FORCE_CONNECTION}, i 0)i.r0"
DetailPrint "InternetCheckConnection returned $0"
System::Alloc 512
Pop $2
System::Call 'Iphlpapi::IcmpCreateFile()i.r0'
System::Call "ws2_32::inet_addr(t '8.8.8.8')i.r1"
System::Call "Iphlpapi::IcmpSendEcho(i $0,i $1,i 0,i 0,i 0,i $2,i 512,i 500)i.r3"
DetailPrint "IcmpSendEcho returned $3"
${If} $3 <> 0
System::Call "*$2(i,i.r5,i.r6,i,i,i)"
DetailPrint "ICMP_ECHO_REPLY: Status=$5 RoundTripTime=$6"
${EndIf}
System::Call "Iphlpapi::IcmpCloseHandle(i $0)"
System::Free $2
thnx for your answer.
what should i use instead of *t
what should i use instead of *t
If you are using NSIS 3 then ideally p but I just used i so it is compatible with 2.46 (but will not work as 64 bit).Originally Posted by mpinkim View Postthnx for your answer.
what should i use instead of *t
Note: The ping code is XP+ because 2000 uses a different .dll. The WinINet code is IE3 or IE4+ IIRC