How to Manage a Dial-up Connection with WebCheck

This topic describes how to keep a dial-up connection open by sending messages to WebCheck, a Windows Shell Service Object. If no messages are received within a timeout period, WebCheck prompts the user to disconnect (hang up the modem).

This topic contains the following sections:

  • What is WebCheck?
  • Alerting the Dial-up Monitor
  • Code Example: Indicating Activity
  • Code Example: Hanging Up
  • Monitoring a Remote Access "Connectoid"

What is WebCheck?

WebCheck was introduced with Microsoft Internet Explorer 4.0 to manage subscription and offline content for Microsoft Active Desktop. It was also used to customize some settings of Windows Internet Explorer and propagate these settings to all users of the computer. Additionally, WebCheck provided a mechanism to monitor activity on a dial-up connection and hang up the phone if no activity was detected within a certain period of time.

WebCheck originally ran as a separate process (loadwc.exe) and appeared as a tray icon in Windows 98. Later, it was converted to a DLL and loaded as a Shell Service Object, running in the same process as Windows Explorer.

Alerting the Dial-up Monitor

The WebCheck dial-up monitor (also known as Dialmon) times out a connection within 20 minutes, by default. However, any application can simulate activity by posting Windows messages directly to Dialmon. When the message is received, Dialmon will reset its idle timer.

When Dialmon starts, it creates a hidden window with a class name of MS_AutodialMonitor or MS_WebcheckMonitor. To find a window with the specified window class name, use FindWindow.

The following Windows messages are defined and can be used to alert the monitor window when dial-up events happen.

#define WM_DIALMON_FIRST        WM_USER+100
#define WM_WINSOCK_ACTIVITY     WM_DIALMON_FIRST + 0
#define WM_SET_CONNECTOID_NAME  WM_DIALMON_FIRST + 2
#define WM_IEXPLORER_EXITING    WM_DIALMON_FIRST + 3 

You may also send registered window messages with the following names. Use RegisterWindowMessage to determine the numeric message identifier.

  • Microsoft.Webcheck.Dialmon.WINSOCK_ACTIVITY
  • Microsoft.Webcheck.Dialmon.SET_CONNECTOID_NAME
  • Microsoft.Webcheck.Dialmon.IEXPLORER_EXITING

These messages may also be sent to Dialmon from a lower-privileged application on Windows Vista.

Code Example: Indicating Activity

To limit the number of messages sent to the WebCheck window, the following example code checks the system timer and sends a WM_WINSOCK_ACTIVITY message only if 15 seconds have elapsed since the previous message.

#define WM_WINSOCK_ACTIVITY    (WM_USER + 100)
#define MIN_ACTIVITY_INTERVAL  15000

static DWORD s_dwLastTickCount = 0;
DWORD dwNewTickCount = GetTickCount();
DWORD dwElapsed = dwNewTickCount - s_dwLastTickCount;

if( dwElapsed >= MIN_ACTIVITY_INTERVAL )
{
    static HWND s_hwndDialmon = NULL;
    HWND hwndMonitor = NULL;

    s_dwLastTickCount = dwNewTickCount;

    // This one is dynamic; find window every time.
    hwndMonitor = FindWindow( TEXT("MS_AutodialMonitor"), NULL );

    if( NULL != hwndMonitor )
    {
        PostMessage( hwndMonitor, WM_WINSOCK_ACTIVITY, 0, 0 );
    }

    // This one lives forever; find it once.
    if( NULL == s_hwndDialmon )
    {
        s_hwndDialmon = FindWindow( TEXT("MS_WebcheckMonitor"), NULL );
    }

    if( NULL != s_hwndDialmon )
    {
        PostMessage( s_hwndDialmon, WM_WINSOCK_ACTIVITY, 0, 0 );
    }
} 

Code Example: Hanging Up

It is also possible to indicate when a dial-up connection is no longer required by sending WM_IEXPLORER_EXITING to the WebCheck monitor window, as follows:

#define WM_IEXPLORER_EXITING    (WM_USER + 103)

// Inform dial-up monitor that it's a good time to hang up.
HWND hwndMonitorWnd = FindWindow( TEXT("MS_AutodialMonitor"), NULL );
if ( NULL != hwndMonitorWnd )
{
    PostMessage( hwndMonitorWnd, WM_IEXPLORER_EXITING, 0, 0 );
}

hwndMonitorWnd = FindWindow( TEXT("MS_WebcheckMonitor"), NULL );
if (NULL != hwndMonitorWnd )
{
    PostMessage( hwndMonitorWnd, WM_IEXPLORER_EXITING, 0, 0 );
} 

Monitoring a Remote Access "Connectoid"

A connectoid is a dial-up connection profile on Windows 98 that describes a connection to various Internet service providers (ISPs). The WM_SET_CONNECTOID_NAME message instructs Dialmon to monitor activity for the current Remote Access connection. A Boolean value can be passed in the wParam of the message; specify TRUE to disable dial-up timeout for the connection. If auto-disconnect is disabled, you will need to send WM_IEXPLORER_EXITING to indicate when you are finished with the connection.