Click here to Skip to main content
11,647,828 members (59,380 online)
Click here to Skip to main content

Checking Internet Is Connected Or Not From .NET

, 16 May 2011 CPOL 8.8K 12
Rate this:
Please Sign up or sign in to vote.
For C# guys....using System ;using System.Runtime ;using System.Runtime.InteropServices ;public class Internet{ [DllImport("wininet.dll")] private extern static bool InternetGetConnectedState( out int Description, int ReservedValue ) ; public static bool...
For C# guys....

using System ;
using System.Runtime ;
using System.Runtime.InteropServices ;
 
public class Internet
{
 
    [DllImport("wininet.dll")]
    private extern static bool InternetGetConnectedState( out int Description, int ReservedValue ) ;
 
    public static bool IsConnectedToInternet( )
    {
        int Desc ;
        return InternetGetConnectedState( out Desc, 0 ) ;
    }
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

J a a n s
Software Developer (Senior)
India India
No Biography provided

You may also be interested in...

Comments and Discussions

 
Generalit doesn't work Pin
The_Brain26-Apr-11 1:02
memberThe_Brain26-Apr-11 1:02 
GeneralReason for my vote of 4 Easy way Pin
Dorababu74322-Apr-11 3:25
memberDorababu74322-Apr-11 3:25 
GeneralReason for my vote of 2 u can directly ping any site without... Pin
--K O-- Solutions18-Apr-11 23:41
member--K O-- Solutions18-Apr-11 23:41 
GeneralReason for my vote of 5 simpler Pin
fdunn318-Apr-11 16:14
memberfdunn318-Apr-11 16:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150804.4 | Last Updated 16 May 2011
Article Copyright 2010 by J a a n s
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid