Page 1 of 1
I can know if there is a network connection on a PC
Posted: Tue Nov 13, 2018 5:31 am
by digitsoft
good day
You can tell me how I can know if there is a network connection on a PC
Thank you
Re: I can know if there is a network connection on a PC
Posted: Thu Nov 15, 2018 9:42 am
by Eugene Lutsenko
Code: Select all
IF InternetGetConnectedState( @n, 0 ) == 0
LB_Warning('The system can not check and download updates, because there is no connection to the Internet!', '(C) Eidos-X++ System"')
RunShell("",executable_module.exe,.T.)
RETURN NIL
ENDIF
[/size]
Re: I can know if there is a network connection on a PC
Posted: Thu Nov 15, 2018 10:46 am
by digitsoft
AND WHERE IS THIS FUNCTION InternetGetConnectedState
Eugene Lutsenko wrote:Code: Select all
IF InternetGetConnectedState( @n, 0 ) == 0
LB_Warning('The system can not check and download updates, because there is no connection to the Internet!', '(C) Eidos-X++ System"')
RunShell("",executable_module.exe,.T.)
RETURN NIL
ENDIF
[/size]
Re: I can know if there is a network connection on a PC
Posted: Thu Nov 15, 2018 11:12 am
by Eugene Lutsenko
I use Boris Borzic's Xb2NET. I have Alaska 1.9. Maybe there's something like that in Alaska 2.0. I don't know. But I suppose there should be.
Code: Select all
DLLFUNCTION InternetGetConnectedState( @nFlags, nReserved ) USING STDCALL FROM WinInet.Dll
[/size]I have everything working perfectly:
http://lc.kubagro.ru/__AIDOS-X.txt. I bought xb2net and several times consulted with Boris. He really, really helped me. Now I can do what I need in Alaska on the Internet.
http://xb2.net/menu.htm
http://xb2.net/xb2net/xb2_200.zip
http://xb2.net/xb2net/xb2_191.zip
Re: I can know if there is a network connection on a PC
Posted: Thu Nov 15, 2018 1:43 pm
by digitsoft
Re: I can know if there is a network connection on a PC
Posted: Thu Nov 15, 2018 3:23 pm
by Jonathan Leeming
Hi,
I use Microsoft's Network List manager API...
https://docs.microsoft.com/en-us/window ... anager-api
Originally just to check for Internet Connection but modified the function to check for either network or internet connections. The MS site lists a number of other methods as well.
Code: Select all
FUNCTION NetworkConnected(pType)
LOCAL lConnected := .F.,;
oNLM
#define CLSID_NetworkListManager "{DCB00C01-570F-4A9B-8D69-199FDBA5723B}"
#define NLM_CONNECTIVITY_IPV4_INTERNET 0x0040
pType := IF(pType==NIL,"I",UPPER(pType))
oNLM:= CreateObject( CLSID_NetworkListManager )
IF pType == "I"
lConnected := oNLM:IsConnectedToInternet()
ELSEIF pType == "N"
lConnected := oNLM:IsConnected()
ENDIF
oNLM:destroy()
RETURN lConnected
If connected the result is returned quickly however if not connected appears to take "a while".
Regards... Jonathan
Re: I can know if there is a network connection on a PC
Posted: Thu Nov 15, 2018 3:38 pm
by rdonnay
InternetGetConnectedState works fine with Xbase++.
There's an eXpress++ sample in \exp20\samples\taskbar\taskbar.prg.