I can know if there is a network connection on a PC

This forum is for eXpress++ general support.
Post Reply
Message
Author
User avatar
digitsoft
Posts: 451
Joined: Thu Jan 28, 2010 1:33 pm
Location: Republica Dominicana
Contact:

I can know if there is a network connection on a PC

#1 Post by digitsoft »

good day
You can tell me how I can know if there is a network connection on a PC
Thank you
Nolberto Paulino
Regards

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: I can know if there is a network connection on a PC

#2 Post 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]

User avatar
digitsoft
Posts: 451
Joined: Thu Jan 28, 2010 1:33 pm
Location: Republica Dominicana
Contact:

Re: I can know if there is a network connection on a PC

#3 Post 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]
Nolberto Paulino
Regards

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: I can know if there is a network connection on a PC

#4 Post 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

User avatar
digitsoft
Posts: 451
Joined: Thu Jan 28, 2010 1:33 pm
Location: Republica Dominicana
Contact:

Re: I can know if there is a network connection on a PC

#5 Post by digitsoft »

Thank you

Eugene Lutsenko wrote: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
Nolberto Paulino
Regards

Jonathan Leeming
Posts: 11
Joined: Wed Feb 28, 2018 2:04 pm
Location: Edmonton, AB, Canada

Re: I can know if there is a network connection on a PC

#6 Post 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

User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: I can know if there is a network connection on a PC

#7 Post by rdonnay »

InternetGetConnectedState works fine with Xbase++.

There's an eXpress++ sample in \exp20\samples\taskbar\taskbar.prg.
The eXpress train is coming - and it has more cars.

Post Reply