
The collection of interfaces available to the developer from Internet Explorer Address Book represents the programmatic techniques necessary to implement the functionality of Internet Explorer Address Book.
If you plan to have your application use Internet Explorer Address Book, your application must register itself for using the wab32.dll as a shared DLL so that the DLL cannot be inadvertently uninstalled while your application is still using it. To do this, you need to increment the reference count of the wab32.dll in the SharedDLLs section in the registry under HKLM\Software\Microsoft\Windows\CurrentVersion\SharedDLLsin the registry.
First get the full path of the installed wab32.dll from:
HKLM\Software\Microsoft\WAB\DLLPath
The default value under this key gives the path of any WAB DLL installed on the computer. (This DLL path is defined in Wabapi.h as WAB_DLL_PATH_KEY; if you are including Wabapi.h in your application, just use the defined WAB_DLL_PATH_KEY symbol as the name of the key to open./) If this key does not exist, the system has a pre-Internet Explorer 4.0 version of Internet Explorer Address Book and you do not need to do any reference counting. on the DLL.
If the above key exists, look under:
HKLM\Software\Microsoft\Windows\CurrentVersion\SharedDLLs
Look for the value of <Full WAB32 Path>. If this value doesn't exist, create it using the Registry API. This is a DWORD value. The content of this value is a reference count representing the number of clients registered to use Internet Explorer Address Book. You should read the reference count from the value, increment it by one, and then save the incremented value back to the registry.
On systems that have Internet Explorer 3.0x or earlier, the Wab32.dll file exists in the windows\system directory. However, on Internet Explorer 4.0 and later platforms, Wab32.dll exists elsewhere, and your application cannot assume it will be able to load the DLL by just using LoadLibrary("wab32.dll"). You should also not statically link your application to Wab32.dll because it might not necessarily be on the path.
Under Internet Explorer 4.0, Wab32.dll is set in the registry in the following location:
HKLM\Software\Microsoft\WAB\DLLPath
The only reason to call LoadLibrary("wab32.dll") is if this key does not exist or if the path set in this key is invalid.
The following sample code shows how to run LoadLibrary on Internet Explorer Address Book.
const static TCHAR lpszWABRegPathKey[] = TEXT("Software\\Microsoft\\WAB\\DLLPath");
const static TCHAR lpszWABDll[] = TEXT("WAB32.dll");
// GetWABDllPath - loads the WAB DLL path from the registry
// szPath - ptr to buffer
// cb - sizeof buffer
//
void GetWABDllPath(LPTSTR szPath, ULONG cb)
{
DWORD dwType = 0;
ULONG cbData = cb;
HKEY hKey = NULL;
if(szPath)
{
*szPath = '\0';
if (ERROR_SUCCESS == RegOpenKeyEx( HKEY_LOCAL_MACHINE,
lpszWABRegPathKey, 0, KEY_READ, &hKey))
RegQueryValueEx( hKey, "", NULL, &dwType, (LPBYTE) szPath, &cbData);
}
if(hKey) RegCloseKey(hKey);
return;
}
// LoadLibrary_WABDll() - Load the WAB library based on the WAB DLL path
//
HINSTANCE LoadLibrary_WABDll()
{
TCHAR szWABDllPath[MAX_PATH];
HINSTANCE hinst = NULL;
GetWABDllPath(szWABDllPath, sizeof(szWABDllPath));
return(hinst = LoadLibrary( (lstrlen(szWABDllPath)) ? szWABDllPath : lpszWABDll ));
}
To create and initialize the first instance of Internet Explorer Address Book, use the following sample code as a guide.
LPWABOPEN lpfnWABOpen = NULL; // defined in WABAPI.H
HINSTANCE hinstWAB = NULL;
//
// Initialize Internet Explorer Address Book and get an instance of IWABObject and IAddrBook
//
HRESULT InitWAB(LPWABOBJECT * lppWABObject,
LPADRBOOK * lppAdrBook)
{
HRESULT hr = E_FAIL;
hinstWAB = LoadLibrary_WABDll();
if(hinstWAB)
{
lpfnWABOpen = (LPWABOPEN) GetProcAddress(hinstWAB, "WABOpen");
if(lpfnWABOpen)
hr = lpfnWABOpen(lppAdrBook, lppWABObject, NULL, 0);
}
return hr;
}
In Internet Explorer 3.0x installations, the default location of Wab32.dll is in the Windows system directory.
<Windows System Directory>\WAB32.dll
When Internet Explorer 4.0 is installed, the file Wab32.dll is renamed with Wab32.ie3 extension so they will not conflict with the newer versions of these files installed by Internet Explorer 4.0 setup. Should it become necessary to uninstall, the old files are renamed back to their original extension so that users can revert back to their exact pre-Internet Explorer 4.0 settings.
An application that plans to work with Wab32.dll under both Internet Explorer 4.0 and Internet Explorer 3.0x should not rely on being able to find Wab32.dll on the path. To see how you can write a single piece of code that can load the WAB32.dll library under both Internet Explorer 4.0 and Internet Explorer 3.0, refer to the sample code earlier in this section.
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.