Programmatically Discovering Whether MAPI Is Present

Application programs can examine the Windows registry to determine whether messaging components have been installed on the computer. The registry key used for this purpose is:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Messaging Subsystem

Table 2-4 shows the entry names to look for. A value of "1" for any entry means that the corresponding component is present on the computer.

Table 2-4. Registry Entries for Determining Whether Messaging Components are Installed

Messaging Component

Registry Entry Name

MAPI

"MAPIX"

Simple MAPI

"MAPI"

CMC

"CMC"

CDO

"OLEMessaging"

Your Visual Basic application has merely to check for these registry entries to determine whether specific messaging components have been installed. Unfortunately, the Visual Basic functions for registry access—SaveSetting, GetSetting, GetAllSettings, and DeleteSetting—are not flexible enough to retrieve data from arbitrary registry keys. Because checking for messaging components is potentially a useful feature, I’ll explain how to access arbitrary registry keys from Visual Basic. I’ll also give you a function that nicely wraps up the cumbersome stuff.

To access arbitrary registry entries, it is necessary to use the Win32 registry API functions RegOpenKeyEx, RegQueryValueEx, and RegCloseKey. Win32 API functions are made available to Visual Basic through Visual Basic’s Declare statement. The Declare statement specifies the name of the desired function, as well ...

Get CDO & MAPI Programming with Visual Basic: now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.