Home
Manage Your Code
Snippet: Is There An Active Internet Connection (C#)
Title: Is There An Active Internet Connection Language: C#
Description: This Code returns if there is an active internet connection on the current computer. Views: 1815
Author: Nesim TUNÇ Date Added: 10/20/2008
Copy Code  
1[DllImport("wininet.dll")]
2
3private static extern bool InternetGetConnectedState(ref uint connected, uint reserved);
4
5static uint uConnection = 0x20;
6
7/// <summary>

8
9/// Returns true if it have detected an active Internet connection.

10
11/// </summary>

12
13public static bool HasInternetConnection
14
15{
16
17get { return InternetGetConnectedState(ref uConnection, 0); }
18
19}
20