求救!!

[复制链接]
查看11 | 回复5 | 2007-10-20 08:38:44 | 显示全部楼层 |阅读模式
VC++.NET做了一个小程序,自动把其它的通讯薄(比如D:/PXALL.WAB)添加入OUTLOOKEXPRESS的通讯薄中.程序是非托管的不必CLR支持的WIN32程序,在VS2005中正常调试,但是运行生成的.EXE则出现异常!!请高人指点!!!

// updateOutlookExpress.cpp : 定义应用程序的入口点。
//
#include "stdafx.h"
#include "wab.h"
#include "Wabapi.h"
#include "updateOutlookExpress.h"
int APIENTRY _tWinMain(HINSTANCE hInstance,

HINSTANCE hPrevInstance,

LPTSTRlpCmdLine,

int nCmdShow)
{

LPWABOPEN lpfnWABOpen = NULL;
// Defined in Wabapi.h.

//LPWABIMPORT

HINSTANCE hinstWAB = NULL;

LPWABOBJECT lppWABObject;

LPADRBOOK lppAdrBook;

HRESULT hr = E_FAIL;

LPWABIMPORTPARAM lpWABParam;


TCHARszWABDllPath[MAX_PATH];
DWORDdwType = 0;
ULONGcbData = 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 );



//hinstWAB = LoadLibrary(L"c:\\Program Files\\Common Files\\System\\wab32&quot

;

if (hinstWAB)

{

lpfnWABOpen = (LPWABOPEN) GetProcAddress(hinstWAB, "WABOpen&quot

;

if (lpfnWABOpen)

{

hr = lpfnWABOpen (&lppAdrBook, &lppWABObject,NULL, 0);

if (hr != S_OK) {

MessageBox(NULL,L"Outlook Express 通讯薄更新失败!",L"Update",MB_OK);

exit(1);

}

lpWABParam=(LPWABIMPORTPARAM)(malloc(sizeof(WABIMPORTPARAM)));

lpWABParam->lpszFileName="d:\\pxall.wab";//"\\\\webproxy\\芳烃\\pxall.wab";

lpWABParam->lpAdrBook=lppAdrBook;

//GetProcAddress(hinstWAB, "WABIMP_IMPORT_WAB&quot

;

hinstWAB=LoadLibrary(L"C:\\Program Files\\Outlook Express\\wabimp.dll&quot

;


lppWABObject->Release();

HRESULT res=lppWABObject->Import((LPSTR)lpWABParam);

if(res!=S_OK){

MessageBox(NULL,L"Outlook Express 通讯薄更新失败!",L"Update",MB_OK);

exit(1);

}

}

}

MessageBox(NULL,L"Outlook Express 通讯薄更新完成!",L"Update",MB_OK);

FreeLibrary(hinstWAB);

return 1;
}
回复

使用道具 举报

千问 | 2007-10-20 08:38:44 | 显示全部楼层
...............................................
回复

使用道具 举报

千问 | 2007-10-20 08:38:44 | 显示全部楼层
........................help
回复

使用道具 举报

千问 | 2007-10-20 08:38:44 | 显示全部楼层



回复

使用道具 举报

千问 | 2007-10-20 08:38:44 | 显示全部楼层
我用的是vb.net,vc.net没用过。
帮你顶 !
回复

使用道具 举报

千问 | 2007-10-20 08:38:44 | 显示全部楼层
多谢!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行