To determine whether a PC currently has Internet access

Using (or providing) components based on the "Win32" framework
User avatar
StefanoLanzavecchia
Posts: 113
Joined: Fri Oct 03, 2008 9:37 am

Re: To determine whether a PC currently has Internet access

Post by StefanoLanzavecchia »

Take Windows Live Messenger as an example. Their "Troubleshoot connection" button, runs several tests, starting from raw TCP/IP communication (to verify that the stack is operational) to trying to talk to the servers in Redmond. I agree with Andy that "currently has Internet access" is hard to define technically...
User avatar
AndyS|Dyalog
Posts: 263
Joined: Tue May 12, 2009 6:06 pm

Re: To determine whether a PC currently has Internet access

Post by AndyS|Dyalog »

btw: back to Phil's original few postings in this thread:

InternetGetConnectedState is defined as returning a BOOL, and has an __out LPDWORD and an __in DWORD as its parameters.

The correct ⎕NA syntax therefore would be

      ⎕NA'I4 WinINet|InternetGetConnectedState >I4 I4'


On my laptop I then get

      InternetGetConnectedState 0 0
1 18


The 1 (the BOOL return value) says that I'm connected to the internet (which since I'm accesssing the Forums seems reasonable) and the 18 (=0x12) says the PC has Remote Access System installed and that it's attached to the internet via a LAN.


On a more general note, I suspect that Dyalog APL generated a syserror 995 and therefore dropped an aplcore, which contains the workspace and some other information. In general syserrors are generated when the interpreter discovers that there's a problem from which it cannot recover; a 995 says that the called DLL function has crashed. You can configure APL so that it will generate a trappable event rather than generating a syserror 995, but it is very much on you head be it .. the underlying function call has failed catastrophically, and it could have scribbled on any part of your workspace. If you set ErrorOnExternalException=1 either on the command line on in the registry, Dyalog APL will generate an error 91, EXTERNAL DLL EXCEPTION, rather than the syserror 995.

You may be able to )copy an aplcore or parts of an aplcore - but if the workspace in the aplcore is damaged, the )copy may also cause APL to crash with a different syserror; I'd recommend taking a copy of the initial aplcore, or configure APL to generate a new aplcore name each time one occurs.

To alter the name of the aplcore, set APLCoreName in the registry (I have it set to aplcore_121U64_* or aplcore_130C32_* etc so that I can tell which version of APL generated the aplcore). To )copy from an aplcore on Windows, don't forget to put a trailing "." on the aplcore name (otherwise APL will append ".DWS" and fail to find the aplcore file).
PhilGray
Posts: 50
Joined: Sat Mar 13, 2010 7:55 pm

Re: To determine whether a PC currently has Internet access

Post by PhilGray »

Thanks Andy ...
BTW, I guessed there was a mistake in my ⎕NA statement, thanks for correcting it.
Post Reply