HOWTO: Programmatically Detect RAS Installation on Workstation

ID: Q181518

The information in this article applies to:

SUMMARY

This article shows how to programmatically detect if RAS is installed on a Workstation.

The sample code included in this article takes into account that RAS might not be installed, even if a copy of the rasapi32.dll exists in the system directory. Also a valid phone book entry and an active modem are not required.

MORE INFORMATION

The way to detect programatically whether or not RAS is installed is to perform a LoadLibrary() on the rasapi32. If the LoadLibrary() fails, RAS is not installed.

The following sample code demonstrates one way to do this. The function RasInstalled returns TRUE if RAS is installed and returns FALSE if RAS is not installed.

Sample Code

   #define WIN32_LEAN_AND_MEAN

   #include <stdio.h>
   #include <windows.h>
   #include <ras.h>
   #include <raserror.h>
   #include <string.h>
   #include <winbase.h>

   BOOL RasInstalled(void)
   {
      HINSTANCE hDLL;      // Handle to DLL.

      hDLL = LoadLibrary("rasapi32");
      if (hDLL != NULL)
      { // RAS is installed.
         return TRUE;
      }
      else
      { // RAS in not installed.
         return FALSE;
      }
   }

Additional query words:
Keywords          : kbnetwork kbAPI kbNTOS400 kbRAS kbSDKPlatform kbWinOS95 kbGrpNet 
Issue type        : kbhowto

Last Reviewed: July 31, 1998