Implementation of POOM Using Embedded Visual C++ 3.0

Environment: EVC++3.0, WinCE, PocketPC SH3 or so

The contactMgt is the application which implements POOM and it has been successfully tested on SH3 processor and hope it will work fine on the rest of too. but before try to build it you need to register the DLL’s on your Pocket PC, I choose regsvrce.exe(find out in Windows CE Tools folder ) for that. And you know which DLL you have to register (I don’t want to repeat things again and again )

Once register DLL now its very easy

The parameter that is passed is the identifier for the folder that is to be retrieved.

Folder Type Value
Calendar 9
Contacts 10
Tasks 13
Cities 101
Infrared 102

If facing any problem in LINKING use Project->Settings->Link and add /force

//
// Include headers
// in stdafx.h
#include “initguid.h>”
#include “pimstore.h”
// Initialize

CoInitializeEx(NULL, 0);

hr = CLSIDFromProgID(POA_OBJECT, &clsid);
if (FAILED(hr))
{
AfxMessageBox(_T(“Fail to load CLSID”));
}
else
{
hr = CoCreateInstance(clsid,
NULL,
CLSCTX_INPROC_SERVER,
IID_IPOutlookApp,
(LPVOID *) &(polApp));
if (FAILED(hr))
{
err = GetLastError();
sprintf(str,”Fail to load CoCreateInstance %d”,err);
AfxMessageBox((CString)str);
}
}

// ///////////in header file
IPOutlookApp *polApp; // outlook app
IFolder *pFolder;
IPOutlookItemCollection *pContacts;

IPOlItems *pItem;
IContact *pContact;

HRESULT hr;
CLSID clsid;

///////////////And Implementation is here
BSTR pwszVersion = NULL;

CString firstname,lastname,fullname;
CListBox* List1=(CListBox *)GetDlgItem(IDC_LIST1);
List1->ResetContent();
int olFolderContacts = 10;

hr = polApp->Logon(NULL);
if (FAILED(hr))
{
AfxMessageBox(_T(“Fail to login”));
}
else
{
polApp->get_Version(&pwszVersion);
polApp->GetDefaultFolder(olFolderContacts, &pFolder);
pFolder->get_Items(&pContacts);
pContacts->QueryInterface(IID_IPOlItems, (LPVOID *) &pItem);

int numItems,i;
pItem->get_Count(&numItems);

for (i = 1; i <= numItems; i++) { pItem->Item(i, (IDispatch **) &pContact);
LPTSTR Fname,Lname;
pContact->get_FirstName(&Fname);
pContact->get_LastName(&Lname);
firstname =(CString)Fname;
lastname = (CString)Lname;
fullname = firstname + ” ” + lastname;
List1->AddString((CString)fullname);
}
}
//

Downloads

Download source – 285 Kb

Download demo application – 5 Kb

More by Author

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Must Read