나는 스마트 COM 포인터를 사용하여 MS Outlook 연락처를 반복하는 일부 ATL 코드이며 일부 PC에서는 각각 COM 오류 0x80004003 ('잘못된 포인터')이 표시됩니다. 접촉. 동일한 코드가 다른 PC에서도 잘 작동합니다. 코드는 다음과 같습니다.COM 오류 0x80004003 (잘못된 포인터) 액세스 MS Outlook 연락처
_ApplicationPtr ptr;
ptr.CreateInstance(CLSID_Application);
_NameSpacePtr ns = ptr->GetNamespace(_T("MAPI"));
MAPIFolderPtr folder = ns->GetDefaultFolder(olFolderContacts);
_ItemsPtr items = folder->Items;
const long count = items->GetCount();
for (long i = 1; i <= count; i++)
{
try
{
_ContactItemPtr contactitem = items->Item(i);
// The following line throws a 0x80004003 exception on some machines
ATLTRACE(_T("\tContact name: %s\n"), static_cast<LPCTSTR>(contactitem->FullName));
}
catch (const _com_error& e)
{
ATLTRACE(_T("%s\n"), e.ErrorMessage());
}
}
다른 응용 프로그램/추가 기능이 원인 일 수 있습니까? 어떤 도움이라도 환영받을 것입니다.
하나의 가능한 체크. contactitem은 항상 null입니까? 나는 당신이 카운트를 미리 체크하고 있기 때문에 그렇게 생각하지 않을 것이다. 그러나 시도할만한 가치가있다. –