a problem in use vc++.net to import WAB file!
It's my first vc++.net program,i want it to import another WAB book from d:/pxall.wab into
my default outlook express WAB book. Under vs2005 i debug it done ok,but double click .exe
file it can't work(my OS is xp)!!when i copy .exe and msvcr80d.dll to win2000 and double
click .exe it done ok!!i copy .exe file and msvcr80d.dll to other xp os it can't work!why??
Can any one help me! thanks!
/ updateOutlookExpress.cpp¡£
//
#include "stdafx.h"
#include "wab.h"
#include "Wabapi.h"
#include "updateOutlookExpress.h"
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
LPWABOPEN lpfnWABOpen = NULL; // Defined in Wabapi.h.
HINSTANCE hinstWAB = NULL;
LPWABOBJECT lppWABObject;
LPADRBOOK lppAdrBook;
HRESULT hr = E_FAIL;
LPWABIMPORTPARAM lpWABParam;
TCHAR szWABDllPath[MAX_PATH];
DWORD dwType = 0;
ULONG cbData = sizeof(szWABDllPath);
HKEY hKey = NULL;
*szWABDllPath = '\0';
// First we look under the default WAB DLL path location in the
// Registry.
// WAB_DLL_PATH_KEY is defined in wabapi.h
//
if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, WAB_DLL_PATH_KEY, 0, KEY_READ,
&hKey))
RegQueryValueEx( hKey, L"", NULL, &dwType, (LPBYTE) szWABDllPath, &cbData);
if(hKey) RegCloseKey(hKey);
// if the Registry came up blank, we do a loadlibrary on the wab32.dll
// WAB_DLL_NAME is defined in wabapi.h
//
hinstWAB = LoadLibrary( (lstrlen(szWABDllPath)) ? szWABDllPath : WAB_DLL_NAME );
if (hinstWAB)
{
lpfnWABOpen = (LPWABOPEN) GetProcAddress(hinstWAB, "WABOpen");
if (lpfnWABOpen)
{
hr = lpfnWABOpen (&lppAdrBook, &lppWABObject,NULL, 0);
if (hr != S_OK) {
MessageBox(NULL,L"Outlook Express WAB Book Update
Failed!",L"Update",MB_OK);
exit(1);
}
lpWABParam=(LPWABIMPORTPARAM)(malloc(sizeof
(WABIMPORTPARAM)));
lpWABParam->lpszFileName="d:\\pxall.wab";
lpWABParam->lpAdrBook=lppAdrBook;
HRESULT res=lppWABObject->Import((LPSTR)lpWABParam);
if(res!=S_OK){
MessageBox(NULL,L"Outlook Express WAB Book Update
Failed!",L"Update",MB_OK);
exit(1);
}
}
}
MessageBox(NULL,L"Outlook Express Wab Book Updated!",L"Update",MB_OK);
FreeLibrary(hinstWAB);
return 1;
}
|