How to: Establish a POOM Session
Before you can create and manipulate PIM items, you must first create an instance of the Pocket Outlook application object and then use it to establish a POOM session, which opens a connection to the PIM database.
To establish a POOM session
Declare and initialize a pointer to the IPOutlookApp interface object:
IPOutlookApp * g_polApp = NULL;
Initialize COM:
CoInitializeEx( NULL, 0);
Create an Application class COM server object:
CoCreateInstance(CLSID_Application, NULL, CLSCTX_INPROC_SERVER, IID_IUnknown, (void **)&g_pUnknown);
Get a reference to the Pocket Outlook application interface object:
g_pUnknown->QueryInterface(IID_IPOutlookApp, (void**)&g_polApp);
Logon to the Pocket Outlook COM server:
g_polApp->Logon(NULL);
Example
The following code demonstrates how to create the application object and then use it to establish a POOM session.
IPOutlookApp * g_polApp = NULL;
IUnknown * g_pUnknown = NULL;
BOOL InitPoom(void) {
BOOL bSuccess = FALSE;
hr = CoInitializeEx( NULL, 0);
if (hr != S_OK) {
// CoInitializeEx failed.
MessageBox(NULL,
_T("CoInitializeEx failed."),
_T("Warning"),
MB_OK);
exit(0); // Replace with specific error handling.;
}
hr = CoCreateInstance(CLSID_Application,
NULL, CLSCTX_INPROC_SERVER,
IID_IUnknown,
(void **)&g_pUnknown);
if (hr != S_OK) {
// CoCreateInstance failed.
MessageBox(NULL, _
_T("CoCreateInstance failed."),
_T("Warning"),
MB_OK);
exit(0); // Replace with specific error handling.;
}
hr = g_pUnknown->QueryInterface(IID_IPOutlookApp, (void**)&g_polApp);
if (hr != S_OK) {
// QueryInterface failed.
MessageBox(NULL,
_T("QueryInterface failed."),
_T("Warning"),
MB_OK);
exit(0); // Replace with specific error handling.;
}
hr = g_polApp->Logon(NULL);
if (hr != S_OK) {
// Logon failed.
MessageBox(NULL,
_T("Logon failed."),
_T("Warning"),
MB_OK);
pOutApp->Release();
exit(0); // Replace with specific error handling.;
}
bSuccess = TRUE;
return bSuccess;
}
See Also
Last updated on Friday, April 22, 2005
© 2005 Microsoft Corporation. All rights reserved.
Send feedback on this topic to the authors.