+ Reply to Thread
Results 1 to 2 of 2

Thread: Check if computer has an internet connection

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    22

    Check if computer has an internet connection

    Say you want to check if the computer has an internet connectivity before opening your application , what should you do ?

    Because i have application that must connect to internet at startup and i'd like to check for internet connectivity.
    Last edited by cross; 11-02-2012 at 01:16 PM.

  2. #2
    Junior Member
    Join Date
    May 2012
    Posts
    27
    that returns a bool value about the status of the internet connectivity.
    Code :
    Code:
    using System.Runtime.InteropServices;
    .
    .
    .
        class Program
        {
            public static void Main()
            {
                Console.WriteLine(IsConnectedToInternet());
            }
            //Creating the extern function...
            [DllImport("wininet.dll")]
            private extern static bool InternetGetConnectedState(out int Description, int ReservedValue);
    
            //Creating a function that uses the API function...
            public static bool IsConnectedToInternet()
            {
                int Desc;
                return InternetGetConnectedState(out Desc, 0);
            }
        }

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts