O'Reilly logo

CDO & MAPI Programming with Visual Basic: by Dave Grundgeiger

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Programmatically Discovering Profile Names and the Default Profile

Application programs can examine the Windows registry to determine the names of the profiles set up for a user, as well as which profile is the user’s default profile. The registry key used for this purpose on a Windows 9x system is:

HKEY_CURRENT_USER\Software\Microsoft\Windows Messaging Subsystem\Profiles

On Windows NT, the key is:

HKEY_CURRENT_USER\Software\Microsoft\WINDOWS NT\CURRENTVERSION\Windows Messaging 
Subsystem\Profiles

Regardless of operating system, the key has a string value called DefaultProfile that contains the name of the user’s default MAPI profile (if the user has a default profile). In addition, the key has a subkey for each profile that has been set up for the user. The name of each subkey corresponds to the name of the associated profile. Example 2-3 shows two functions for accessing this information on a Windows 9x machine. GetDefaultProfileName returns the user’s default profile name, and GetProfileNames returns a string array containing the names of the user’s profiles. As in Example 2-2, several registry-related constants and API functions must be declared.

Example 2-3. Obtaining Profile Names from the Windows 9x Registry

' Place these declarations at the module level. Public Const HKEY_LOCAL_MACHINE = &H80000002 Public Const HKEY_CURRENT_USER = &H80000001 Public Const KEY_QUERY_VALUE = &H1 Public Const ERROR_SUCCESS = 0& Public Const ERROR_FILE_NOT_FOUND = 2& Public Type FILETIME dwLowDateTime ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required