I often notice that my anti-virus starts automatic update when internet connection is available. How does these applications detect internet connection?


You can use the api – InetIsOffline(). If internet connection is not available, it will return true else false. See the sample code snippet below.

#include "intshcut.h"
...

// Check whether internet connection is enabled.
if( !InetIsOffline( 0 ))
{
    // Internet connection is available.
    // Do automatic updates.
}


Don’t forget to add library – url.lib to your project settings.


Targeted Audience – Beginners.