Windows Mobile 建立与短信信箱的连接
2010-06-03 22:56:00 来源:WEB开发网//查找显示名字为SMS的行记录
if (_tcsicmp(m_pRows->aRow[0].lpProps[1].Value.lpszW, _T("SMS")) == 0)
{
ULONG ulMsgType;
//则获取指向短信仓库的对象
hr=m_pSession->OpenEntry(m_pRows->aRow[0].lpProps[0].Value.bin.cb,
(LPENTRYID)m_pRows->aRow[0].lpProps[0].Value.bin.lpb,
NULL,
MAPI_BEST_ACCESS,
&ulMsgType,
(LPUNKNOWN*)&m_pMsgStore);
if(FAILED(hr) || NULL==m_pMsgStore)
{
//异常处理
}
break;
}
FreeProws(m_pRows); //释放
m_pRows = NULL;
}
if(m_pRows) //释放资源
{
FreeProws(m_pRows);
m_pRows = NULL;
}
}
//获取指向具体信箱的IMAPIFolder接口对象
void Folder(ULONG ulType)
{
HRESULT hr=0;
LPSPropValue stProps = NULL;
ULONG ulValues = 0;
ULONG ulTags[] = { 1, ulType};
// 获取Folder的Entry ID,然后通过OpenEntry获得对象
m_pMsgStore->GetProps((LPSPropTagArray) ulTags, MAPI_UNICODE, &ulValues, &stProps);
hr=m_pMsgStore->OpenEntry(stProps[0].Value.bin.cb, (LPENTRYID)stProps[0].Value.bin.lpb, NULL, MAPI_MODIFY, NULL, (LPUNKNOWN*)&m_pFolder );
if(FAILED(hr) || NULL==m_pFolder)
{
throw(CMsgException(_T("获取FOLDER失败!"),_T("CMsgControl->Folder"),ERR_GET_FOLDER));
}
MAPIFreeBuffer(stProps); //释放掉对象
}
//释放掉IMAPISession、IMsgStore、IMAPIFolder对象
void UnInit()
{
if(NULL!=m_pSession) //释放Session
{
m_pSession->Logoff(NULL,NULL,NULL);
m_pSession->Release();
m_pSession=NULL;
}
if(NULL!=m_pMsgStore) //释放MsgStore
{
m_pMsgStore->Release();
m_pMsgStore=NULL;
}
if(NULL!=m_pFolder) //释放Folder
{
m_pFolder->Release();
m_pMsgStore=NULL;
}
}
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/depraved_survival/archive/2009/03/08/3970490.aspx
赞助商链接