Guest Vanderhuge Posted July 28, 2005 Report Posted July 28, 2005 Hi, I want to write an app that will check for changes in appointments and/or tasks evetytime it is run. Does anyone know an easy way to do this? Thanks
Guest tedp Posted August 27, 2005 Report Posted August 27, 2005 (edited) Hi, I want to write an app that will check for changes in appointments and/or tasks evetytime it is run. Does anyone know an easy way to do this? Thanks <{POST_SNAPBACK}> An easy way? No. And it is, apparently, going to change for the next release of Windows Mobile. According to Microsoft, the current calendar plugins and applications also make use of APIs that are unsupported for the general public and will have to change at that time too. Here is what I got from the folks on smartphone.developer at Microsoft. Unfortunately that thread has gone away so the very succinct description is going to be diluted by my heavy handed coding style :) Please note that I am only registering for calendar events, not tasks. You'll have to modify this code slightly to work with that. Grap a handle to the outlook application. For my purposes this is stored in a global. // Globals IPOutlookApp * g_polApp = NULL; int g_PoomInit = 0; // ************************************************************************** // Function Name: GetPoomApp // // Purpose: Gets pointer to POOM application interface // // Arguments: // OUT IFolder ** ppFolder - pointer to IPOutlookApp interface returned. // Must be released by caller of GetPoomApp // // Return Values: // BOOL // returns TRUE if the folder interface was retrieved, FALSE otherwise // // Description: // This function simply returns a pointer to the global Outlook app interface // The returned pointer is simply passed through this function after being AddRef'd. BOOL GetPoomApp(IPOutlookApp **ppOutApp) { if (g_polApp) { g_polApp->AddRef(); *ppOutApp = g_polApp; return TRUE; } else { return FALSE; } } Initialize POOM // ************************************************************************** // Function Name: InitPoom // // Purpose: Creates and logs on to the POOM application object // // Arguments: // none // // Return Values: // BOOL // returns TRUE if POOM was initialized, FALSE otherwise // // Description: // This function creates the POOM application COM object and starts a POOM // session via Logon. This must be done before any subsequent POOM calls are // made. This function may be called repeatedly on an already initialized connection. BOOL InitPoom() { BOOL bSuccess = FALSE; if (!g_polApp) { if (SUCCEEDED(CoInitializeEx( NULL, 0))) { // Now, let's get the main outlook application g_PoomInit++; if (SUCCEEDED(CoCreateInstance(CLSID_Application, NULL, CLSCTX_INPROC_SERVER, IID_IPOutlookApp, reinterpret_cast<void **>(&g_polApp)))) { // login to the Pocket Outlook object model g_PoomInit++; if(SUCCEEDED(g_polApp->Logon(NULL))) { bSuccess = TRUE; } } } } else { bSuccess = TRUE; //we're ok...just got called when already initialized. } return bSuccess; } De-Initialize Poom // ************************************************************************** // Function Name: ShutdownPoom // // Purpose: Shuts down the current POOM session // // Arguments: // none // // Return Values: // none // // Description: // This function logs off the current POOM session and releases the POOM // application interface pointer. Sets it to NULL in case the thing gets called // multiple times. void ShutdownPoom() { // if this dude is NULL, make sure you don't call call CoUnitialize(). That's a pretty good sign that // the CoInitialize hasn't been called yet. Anyway, if it's NULL, just return. if (g_polApp) { g_polApp->Logoff(); g_polApp->Release(); g_polApp = NULL; g_PoomInit =0; CoUninitialize(); } } Register for POOM events LRESULT BackgroundWindow::RegisterForDBNotification(void) { LRESULT lr = 0; CENOTIFYREQUEST req; CEOIDINFO oidInfo; CEOID oid; CEGUID guid; unsigned short volName[MAX_PATH]; HANDLE m_hDB = NULL; //initialize all of our objects appropriately memset(&req, 0, sizeof(req)); memset(&oidInfo, 0, sizeof(oidInfo)); memset(&oid, 0, sizeof(oid)); CREATE_INVALIDGUID(&guid); memset(volName, 0, MAX_PATH); // set up the pertinent fields in the request structure req.dwSize = sizeof(req); req.hwnd = GetHwnd(); req.dwFlags = CEDB_EXNOTIFICATION; req.hHeap = 0; req.dwParam = 0; while (CeEnumDBVolumes(&guid, volName, MAX_PATH)) { HANDLE h = CeFindFirstDatabaseEx(&guid, 0); ASSERT(h != INVALID_HANDLE_VALUE ); while (oid = CeFindNextDatabaseEx(h, &guid), oid) { if (CeOidGetInfoEx(&guid, oid, &oidInfo)) { if (lstrcmp(oidInfo.infDatabase.szDbaseName, L"Appointments Database") == 0) { m_hDB = CeOpenDatabaseEx2( &guid, &oid, NULL, 0, CEDB_AUTOINCREMENT, &req); } } } } return(lr); } And finally in my WinMain, handle the message when it gets sent to me. Note that I was writing a plugin rather than an application so I'm notifying the plug-in rather than updating information in my window directly. LRESULT BackgroundWindow::WindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam) { LRESULT lr = 0; switch (uMsg) { case WM_CREATE: { RegisterForDBNotification(); // should register for DB notification here. break; } case WM_CLOSE: { DestroyWindow(GetHwnd()); break; } case WM_DESTROY: { PostQuitMessage(0); break; } case WM_DBNOTIFICATION: { // send data change message to plug-in. SHOnPluginDataChange(CLSID_MULTICAL); break; } default: { lr = DefWindowProc(GetHwnd(), uMsg, wParam, lParam); break; } } return(lr); } Ted Edited August 27, 2005 by tedp
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now