c# - How yo know if my PC is connected to Internet?

pinkerton1981

New Member
Joined
Oct 29, 2011
Messages
20
Reaction score
0
Points
0
Hi,

Another tip today! So, to know if your PC is connected to Internet, you can use the InternetGetConnectedState function from wininet.dll like this:
Code:
[COLOR=DarkBlue]using System.Runtime.InteropServices;

// API declaration
[DllImport("[COLOR=blue][B]wininet.dll[/B][/COLOR]")]
public extern static bool [B][COLOR=blue]InternetGetConnectedState[/COLOR][/B]( out int Description, int ReservedValue ) ;

// API using
public static bool IsConnected()
{
     int Desc ;
     return[COLOR=blue][B] InternetGetConnectedState[/B][/COLOR]( out Desc, 0 ) ;
}[/COLOR]
Be careful to the ghosts tonight ;)

pinkerton1981
 

hu_yang

New Member
Joined
Jan 22, 2012
Messages
1
Reaction score
0
Points
0
net-informations.com/csprj/communications/internet-connection.htm