Internet connected or not
Moderator: Rathinagiri
-
- Posts: 190
- Joined: Wed Jan 06, 2010 5:39 pm
Re: Internet connected or not
Very interesting. Thanks for the sharing
Re: Internet connected or not
Interesting code. thanks for sharing!
however I'm a bit sceptical about its reliability, since i got:
"Ping to 0.1.0.1 Succesful"
for xurl := "0.1.0.1"
(needless to say that doing a C:\>ping 0.1.0.1 (in command line)
returns as expected "PING: transmission failed. General failure.")
regards,
---
Pete
Re: Internet connected or not
Strange, I've got message "Internet Connection Not Available" and variable xerrdescription is 1231. Tested on Win10 32b and HMG 3.4.4
Re: Internet connected or not
Nice suggestion. Thank you very much!KDJ wrote: ↑Mon Jun 19, 2017 8:20 pm This is probably the simplest way with PINGing:
Code: Select all
FUNCTION Main() // https://msdn.microsoft.com/en-us/library/windows/desktop/aa384346(v=vs.85).aspx LOCAL lIsInternet := If(HMG_CallDLL("Wininet.dll", 0, "InternetCheckConnection", "http://www.google.com", 1 /*FLAG_ICC_FORCE_CONNECTION*/, 0) == 1, .T., .F.) MsgBox("Is internet: " + HB_ValToStr(lIsInternet)) RETURN NIL
(Although I didn't understand what you mean by "with PINGing").
Now, as a general remark I'd say that DLL calls is not the preffered method, for me, to exploit windows functionality,
when it's easy to implement relevant functions "natively" in harbour.
f.e.:
Code: Select all
PROCEDURE Main
LOCAL isInet := InternetCheckConnection( "https://www.google.com" )
? "=============================="
? "Internet " + If ( isInet, "available!", "not available" )
? InternetCheckConnection() // -> .T. (it works even without Url, as it's documented)
RETURN
#pragma BEGINDUMP
#include <hbapi.h>
#include <windows.h>
#include <wininet.h>
HB_FUNC( INTERNETCHECKCONNECTION )
{
const char * cUrl = hb_parc( 1 );
hb_retl( (HB_BOOL) InternetCheckConnection( cUrl, FLAG_ICC_FORCE_CONNECTION, 0 ) );
}
#pragma ENDDUMP
However I'd like to hear different opinions (if any) on that.
regards,
---
Pete
Re: Internet connected or not
Really? then it's strange indeed...
Please note that I have built/run the sample using HMG-extended with MinGW32 7.1.0 on Windows 7 pro.
Don't know if it's enough to explain the different results, though. (i'm going to build with HMG official and see..)
Re: Internet connected or not
I've got message "Internet Connection Not Available",too. Tested on WindowsXp 32b and HMG 3.4.4PeteWG wrote: ↑Wed Jun 21, 2017 8:29 amInteresting code. thanks for sharing!
however I'm a bit sceptical about its reliability, since i got:
"Ping to 0.1.0.1 Succesful"
for xurl := "0.1.0.1"
(needless to say that doing a C:\>ping 0.1.0.1 (in command line)
returns as expected "PING: transmission failed. General failure.")
regards,
---
Pete
Re: Internet connected or not
Well! i attach the executable i have made with HMG 3.4.3.
Could you please test it to see what it returns on your machine/OS?
regards,
---
Pete
- Attachments
-
- ping.zip
- (1.44 MiB) Downloaded 230 times
Re: Internet connected or not
"Internet Connection Not Available" on Win10 Pro 32 and WinXp on VM and Server2012r2
Re: Internet connected or not
I confirm same result as posted by EDK
BPD
Convert Dream into Reality through HMG
Convert Dream into Reality through HMG