TOutlookApplication取地址薄(100)

  • 主题发起人 主题发起人 dongxia
  • 开始时间 开始时间
D

dongxia

Unregistered / Unconfirmed
GUEST, unregistred user!
查询旧帖子,看到的回复,但我在 BCB6 上没有试成功。 原帧在http://topic.csdn.net/t/20060321/15/4629194.html 上, 有这个贴子。我的问题是: 1. #pragma link "IvDictio " #pragma link "IvMulti " 这2个链接的文件,在BCB6上没找到 怎么找到这2个文件? 2. 里面用到一些类型如LPWABOBJECT,需加上头文件 #include <wabapi.h> #include <wabiab.h> 编译时又会提示,WCHAR 重复声明等。 有用BCB或改成delphi调试成功,取到地址的大哥,请回复,多谢。 原有帖子是: ================================================ 用Office组件操作Outlook cpp前面要声明 #pragma link "Outlook_2K_SRVR " #pragma link "IvDictio " #pragma link "IvMulti " typedef HRESULT (WINAPI *fWABOpen)(LPADRBOOK*,LPWABOBJECT*,LPWAB_PARAM,DWORD); 用了bcb的outlook控件的 代码 try { FormList-> ListView1-> Clear(); _ApplicationPtr pApp; _NameSpace* pNS; AddressLists* pAddr; AddressEntries * pAddrEntries; AddressEntry* pEntry; AddressList* pList; int count,count1; pApp = this-> OutlookApplication1-> get_Application(); pNS = pApp-> GetNamespace(WideString( "MAPI ")); pAddr = pNS-> AddressLists; count = pAddr-> Count; WideString email; email.SetLength(128); //emailname.SetLength(128); for(int i = 1;i <= count;i++) { pList = pAddr-> Item(TVariant(i)); pAddrEntries = pList-> get_AddressEntries(); count1 = pAddrEntries-> Count; for(int j = 1;j <= count1;j++) { pEntry = pAddrEntries-> Item(TVariant(j)); //pEntry-> get_Name(&emailname); pEntry-> get_Address(&email); //this-> Memo1-> Lines-> Add(AnsiString(emailname.c_bstr()) + "/t " + AnsiString(email.c_bstr())); TListItem * ListItem; ListItem = FormList-> ListView1-> Items-> Add(); ListItem-> Caption = " "; ListItem-> SubItems-> Add(AnsiString(email.c_bstr())); ListItem-> Checked = true; } } ListView1-> SetFocus(); ListView1-> Update(); } catch(...) { try { HRESULT hRes; //LPADRBOOK lpAdrBook; DelphiInterface lpAdrBook; //LPWABOBJECT lpWABObject; DelphiInterface lpWABObject; //LPWAB_PARAM lpWABParam = NULL; DWORD Reserved2 = NULL; char szPath[MAX_PATH]; SHGetFolderPathX(szPath); char * s = "//System//wab32.dll "; strcat(szPath, s); HINSTANCE hinstLib; hinstLib = LoadLibrary(szPath); // hinstLib = LoadLibrary(s.c_str()+ "//System//wab32.dll "); fWABOpen procWABOpen; if (hinstLib != NULL) { // 获取 "Wab32.dll "内部涵数WABOpen的进程地址 procWABOpen = (fWABOpen) GetProcAddress(hinstLib, "WABOpen "); if (procWABOpen != NULL) { hRes = (procWABOpen)(&lpAdrBook,&lpWABObject,NULL,Reserved2); //_ASSERTE(hRes == S_OK); if (hRes != S_OK) exit(1); ULONG lpcbEntryID; ENTRYID *lpEntryID; hRes = lpAdrBook-> GetPAB(&lpcbEntryID, &lpEntryID); //_ASSERTE(hRes == S_OK); if (hRes != S_OK) exit(2); ULONG ulFlags = MAPI_BEST_ACCESS; ULONG ulObjType = NULL; //LPUNKNOWN lpUnk = NULL; DelphiInterface lpContainer; hRes = lpAdrBook-> OpenEntry(lpcbEntryID, lpEntryID, NULL, ulFlags, &ulObjType, (LPUNKNOWN FAR *)&lpContainer ); ulFlags = NULL; if (ulObjType == MAPI_ABCONT) { //IABContainer *lpContainer = static_cast (lpUnk); LPMAPITABLE lpTable = NULL; hRes = lpContainer-> GetContentsTable(ulFlags, &lpTable); //_ASSERT(lpTable); ULONG ulRows; hRes = lpTable-> GetRowCount(0,&ulRows); //_ASSERTE(hRes == S_OK); SRowSet *lpRows; hRes = lpTable-> QueryRows( ulRows, // 获取所有行 0, &lpRows ); ListView1-> Clear(); for(ULONG i=0;icRows;i++) { SRow *lpRow = &lpRows-> aRow; AnsiString strTemp; for(ULONG j=0;jcValues;j++) { SPropValue *lpProp = &lpRow-> lpProps[j]; if (lpProp-> ulPropTag == PR_EMAIL_ADDRESS_A) { TListItem * ListItem; ListItem = FormList-> ListView1-> Items-> Add(); ListItem-> Caption = " "; ListItem-> SubItems-> Add((char *)lpProp-> Value.lpszA); //strTemp =(char *)lpProp-> Value.lpszA; ListItem-> Checked = true; } } //ListEmail-> Lines-> Add(strTemp); lpWABObject-> FreeBuffer(lpRow); } lpWABObject-> FreeBuffer(lpRows); } } //FreeLibrary(hinstLib);(不注释掉就出错,还在郁闷中) } } catch(...) { MessageBox(Handle, "没有找到地址薄! ", "提示信息 ",MB_OK); }
 

Similar threads

后退
顶部