Click here to Skip to main content
11,576,060 members (58,558 online)
Click here to Skip to main content

Checking Internet Is Connected Or Not From .NET

, 16 May 2011 CPOL 8.5K 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

 
GeneralMy vote of 5 Pin
Nikolay Aph K.1-Feb-13 2:35
memberNikolay Aph K.1-Feb-13 2:35 
GeneralMy vote of 5 Pin
Oshtri Deka14-Jun-12 3:26
memberOshtri Deka14-Jun-12 3:26 
GeneralReason for my vote of 5 Simple and Effective... Pin
Pravin Patil, Mumbai7-Oct-11 8:31
memberPravin Patil, Mumbai7-Oct-11 8:31 
GeneralHood :) Pin
pranav9525-May-11 21:34
memberpranav9525-May-11 21:34 
GeneralReason for my vote of 5 Good :) Pin
pranav9525-May-11 21:34
memberpranav9525-May-11 21:34 
GeneralReason for my vote of 5 Nice simple clean Pin
Chona117125-May-11 2:59
memberChona117125-May-11 2:59 
Generalif u need the code vb.net refer this Private Declare Funct... Pin
bisharbn16-May-11 5:09
memberbisharbn16-May-11 5:09 
GeneralReason for my vote of 5 Nice and simple... Pin
Rhuros16-May-11 2:21
memberRhuros16-May-11 2:21 
GeneralReason for my vote of 3 see my previous comment Pin
charles henington29-Apr-11 13:49
membercharles henington29-Apr-11 13:49 
Reason for my vote of 3
see my previous comment
GeneralWorks just fine brain i've even checked myself although one ... Pin
charles henington29-Apr-11 13:48
membercharles henington29-Apr-11 13:48 
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.150603.1 | Last Updated 16 May 2011
Article Copyright 2010 by J a a n s
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid