![]() |
C++, ATL: Access of folder content by index fails
I have a very simple COM-add-in where I try to access a folder.
But the direct access by index fails: CComPtrOutlook::_NameSpace NameSpace; m_spApp-GetNamespace(L"MAPI", &NameSpace); CComPtrOutlook::MAPIFolder InBoxFolder; CComPtrOutlook::MAPIFolder RootFolder; NameSpace-GetDefaultFolder(Outlook::olFolderInbox, &InBoxFolder); InBoxFolder-get_Parent((IDispatch **)&RootFolder); CComPtrOutlook::_Folders Folders; RootFolder-get_Folders(&Folders); Outlook::MAPIFolder * pFolder = NULL; HRESULT hr = Folders-GetFirst(&pFolder); ATLASSERT(hr == S_OK); hr = Folders-Item(CComVariant(0), &pFolder); ATLASSERT(hr == S_OK); The second ATLASSERT() fails (out of bounds) whereas the first succeeds! Why? |
C++, ATL: Access of folder content by index fails
Got it. The Item property works not zero based. My god. Ron. |
C++, ATL: Access of folder content by index fails
=?Utf-8?B?Um9u?= wrote in news:930E0516-
: Got it. The Item property works not zero based. My god. This is because people using the OOM are expected to be using VB, which is 1-based. You should also be careful about assuming that 'true' = 1, and you'll have to do some casting between string types to get things in/out of BSTR. See http://support.microsoft.com/kb/260626/en-us for some sample code, though they're using #import to get the TLB info so the class names are a bit different. -- dan |
All times are GMT +1. The time now is 02:23 PM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com