Click here to Skip to main content
Click here to Skip to main content
Alternative Tip
Go to top

Checking Internet Is Connected Or Not From .NET

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

Comments and Discussions

 
GeneralMy vote of 5 PinmemberNikolay Aph K.1-Feb-13 2:35 
GeneralMy vote of 5 PinmemberOshtri Deka14-Jun-12 3:26 
GeneralReason for my vote of 5 Simple and Effective... PinmemberPravin Patil, Mumbai7-Oct-11 8:31 
GeneralHood :) Pinmemberpranav9525-May-11 21:34 
GeneralReason for my vote of 5 Good :) Pinmemberpranav9525-May-11 21:34 
GeneralReason for my vote of 5 Nice simple clean PinmemberChona117125-May-11 2:59 
Generalif u need the code vb.net refer this Private Declare Funct... Pinmemberbisharbn16-May-11 5:09 
GeneralReason for my vote of 5 Nice and simple... PinmemberRhuros16-May-11 2:21 
GeneralReason for my vote of 3 see my previous comment Pinmembercharles henington29-Apr-11 13:49 
GeneralWorks just fine brain i've even checked myself although one ... Pinmembercharles henington29-Apr-11 13:48 
Generalit doesn't work PinmemberThe_Brain26-Apr-11 1:02 
GeneralReason for my vote of 4 Easy way PinmemberDorababu74322-Apr-11 3:25 
GeneralReason for my vote of 2 u can directly ping any site without... Pinmember--K O-- Solutions18-Apr-11 23:41 
GeneralReason for my vote of 5 simpler Pinmemberfdunn318-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 | Mobile
Web01 | 2.8.140916.1 | Last Updated 16 May 2011
Article Copyright 2010 by J a a n s
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid