毕业论文开发语言企业开发JAVA技术.NET技术WEB开发Linux/Unix数据库技术Windows平台移动平台嵌入式论文范文英语论文
您现在的位置: 毕业论文 >> 嵌入式 >> 正文

windows mobile 如何获取最近或者最后一条未读短信

更新时间:2012-12-31:  来源:毕业论文

windows mobile 如何获取最近或者最后一条未读短信
通过注册表只能查询到未查看短信数量,没有内容,不知道怎么办。

或者有没有什么直接调用的方法?
已经搞定了,用的是advisesink
cpp

C/C++ code? #include "stdafx.h" #include "AdviseSink.h"   HWND hTBwnd = NULL;   CAdviseSink::CAdviseSink(){} CAdviseSink::~CAdviseSink(){} HRESULT CAdviseSink::QueryInterface(REFIID iid, void** ppvObject){return NULL;} ULONG CAdviseSink::AddRef(){return 0;} ULONG CAdviseSink::Release(){return 0;}   ULONG CAdviseSink::OnNotify(ULONG cNotif, LPNOTIFICATION lpNotifications) {            // cNotif : 指定有多少个Notification通知     // lpNotifications : Notification数组,个数为cNotif     for(int i=0; i<(int)cNotif; i++)     {         // 根据不同的Notification类型做不同的处理         switch(lpNotifications[i].ulEventType)         {         case fnevNewMail:         case fnevObjectCreated:                         SendMessage(hTBwnd, WM_SMSUNREAD, 0, 0);             break;           default:             break;           }     }       return 0; }   BOOL CAdviseSink::InstallListen(HWND hWnd) {     hTBwnd = hWnd;     // session变量,在停止使用MAPI前,请不要释放它     IMAPISession* m_pSession = NULL;          // COM初始化     CoInitializeEx(NULL, COINIT_MULTITHREADED);       MAPIInitialize(NULL);     MAPILogonEx(NULL, NULL, NULL, NULL, &m_pSession);       // IMAPITABLE,通过它我们可以访问数据,比如拿Store,拿Folder,拿Message等,方法都类似,下面会有介绍     LPMAPITABLE pTable  = NULL;     ULONG lCount   = 0;     HRESULT hr  = 0;     LPSRowSet pRows  = NULL;     pMsgStore = NULL;       // 通过下面的定义,我们告诉系统,我们需要获取以下两个属性,一个是Entry ID,通过它我们可以获取Store对象,一个是Display Name,我们用它来比较是不是我们需要的Store     SizedSPropTagArray(2, Columns) = {2, PR_ENTRYID, PR_DISPLAY_NAME};       m_pSession->GetMsgStoresTable(MAPI_UNICODE , &pTable);     pTable->SetColumns((LPSPropTagArray)&Columns, 0);       while(SUCCEEDED(pTable->QueryRows(1, 0, &pRows)))     {           if (NULL == pRows || pRows->cRows != 1)         {             break;         }           //开始一条条记录查询,pRows->aRow[0].lpProps[0]代表了第一个查询属性,即Entry ID,pRows->aRow[0].lpProps[1]则表示Display Name。         if (_tcsicmp(pRows->aRow[0].lpProps[1].Value.lpszW, _T("SMS")) == 0)         {             ULONG ulMesageType;               //如果是SMS,则获取Store对象             m_pSession->OpenEntry(pRows->aRow[0].lpProps[0].Value.bin.cb,                 (LPENTRYID)pRows->aRow[0].lpProps[0].Value.bin.lpb,                 NULL,                  MAPI_BEST_ACCESS,                  &ulMesageType,                 (LPUNKNOWN*)&pMsgStore);             break;         }           FreeProws(pRows);         pRows = NULL;     }     if(pRows)     {         FreeProws(pRows);         pRows = NULL;     }       g_pAdviseSink = new CAdviseSink();     m_ulAdviseSink = 0; //用来标识AdviseSink,当取消注册时我们需要用到它。       ULONG uEventMask = fnevNewMail | fnevObjectCreated;      pMsgStore->Advise(0, NULL, uEventMask, g_pAdviseSink, &m_ulAdviseSink);       return TRUE; }   BOOL CAdviseSink::UninstallListen() {     if(m_ulAdviseSink)     {         pMsgStore->Unadvise(m_ulAdviseSink);     }     //记的释放对象     if(g_pAdviseSink)     {         delete g_pAdviseSink;         g_pAdviseSink = NULL;     }       return TRUE; }

h

C/C++ code?  #include "stdafx.h"   #define WM_SMSUNREAD WM_USER+7231   class CAdviseSink : public IMAPIAdviseSink  { public:     CAdviseSink();     ~CAdviseSink();     MAPIMETHOD_(ULONG,OnNotify)(ULONG cNotif, LPNOTIFICATION lpNotifications);     MAPIMETHOD(QueryInterface)(REFIID iid, void** ppvObject);     MAPIMETHOD_(ULONG, AddRef)();     MAPIMETHOD_(ULONG, Release)();     BOOL InstallListen(HWND hWnd);     BOOL UninstallListen();   private:     ULONG              m_cRef;       ULONG m_ulAdviseSink;     IMsgStore* pMsgStore;     CAdviseSink* g_pAdviseSink; };

设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©youerw.com 优尔论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。