本文整理汇总了C++中LPMAPITABLE::FindRow方法的典型用法代码示例。如果您正苦于以下问题:C++ LPMAPITABLE::FindRow方法的具体用法?C++ LPMAPITABLE::FindRow怎么用?C++ LPMAPITABLE::FindRow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPMAPITABLE
的用法示例。
在下文中一共展示了LPMAPITABLE::FindRow方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetCurrentProfileName
HRESULT GetCurrentProfileName(IN LPMAPISESSION& lpSession, OUT std::string* szProfileName)
{
if ( !szProfileName->empty() )
return S_OK;
HRESULT hr = GetCurrentMAPISession(lpSession);
if ( FAILED(hr) )
return hr;
LPMAPITABLE lpStatusTable = NULL;
SRestriction sres;
SPropValue spvResType;
LPSRowSet pRows = NULL;
LPTSTR lpszProfileName = NULL;
SizedSPropTagArray(2, Columns) =
{
2,
PR_DISPLAY_NAME,
PR_RESOURCE_TYPE
};
hr = lpSession->GetStatusTable(NULL, &lpStatusTable);
if ( SUCCEEDED(hr) )
hr = lpStatusTable->SetColumns((LPSPropTagArray)&Columns, NULL);
if ( SUCCEEDED(hr) )
{
spvResType.ulPropTag = PR_RESOURCE_TYPE;
spvResType.Value.ul = MAPI_SUBSYSTEM;
sres.rt = RES_PROPERTY;
sres.res.resProperty.relop = RELOP_EQ;
sres.res.resProperty.ulPropTag = PR_RESOURCE_TYPE;
sres.res.resProperty.lpProp = &spvResType;
if ( SUCCEEDED(hr) )
hr = lpStatusTable->Restrict(&sres, TBL_ASYNC);
if ( SUCCEEDED(hr) )
hr = lpStatusTable->FindRow(&sres, BOOKMARK_BEGINNING, 0);
if ( SUCCEEDED(hr) )
hr = lpStatusTable->QueryRows(1,0,&pRows);
if (SUCCEEDED(hr))
{
lpszProfileName = pRows->aRow[0].lpProps[0].Value.lpszA;
*szProfileName = lpszProfileName;
}
}
ULRELEASE(lpStatusTable);
FREEPROWS(pRows);
if ( FAILED(hr) )
PR_TRACE((0, prtIMPORTANT, "GetCurrentProfileName failed"));
return hr;
}
示例2: GetFavorite
/**
* Check if the favorite is exist. If the favorite is exist, it will returns the favorite data
* @param ulFlags unicode flag (unused, since SetColumns always sets the correct tags)
*/
HRESULT GetFavorite(IMAPIFolder *lpShortcutFolder, ULONG ulFlags, IMAPIFolder *lpMapiFolder, ULONG *lpcValues, LPSPropValue *lppShortCutPropValues)
{
HRESULT hr = hrSuccess;
LPSPropValue lpPropSourceKey = NULL;
LPMAPITABLE lpTable = NULL;
LPSPropValue lpShortCutPropValues = NULL;
ULONG cShortCutValues = 0;
LPSRestriction lpRestriction = NULL;
SRowSet *lpRows = NULL;
if (lpShortcutFolder == NULL || lpMapiFolder == NULL) {
hr = MAPI_E_INVALID_PARAMETER;
goto exit;
}
hr = HrGetOneProp(lpMapiFolder, PR_SOURCE_KEY, &lpPropSourceKey);
if (hr != hrSuccess) {
hr = MAPI_E_CORRUPT_DATA;
goto exit;
}
// Check for duplicates
hr = lpShortcutFolder->GetContentsTable(ulFlags, &lpTable);
if (hr != hrSuccess)
goto exit;
hr = lpTable->SetColumns(GetShortCutTagArray(), 0);
if(hr != hrSuccess)
goto exit;
// build restriction
CREATE_RESTRICTION(lpRestriction);
CREATE_RES_AND(lpRestriction, lpRestriction, 1);
DATA_RES_PROPERTY(lpRestriction, lpRestriction->res.resAnd.lpRes[0], RELOP_EQ, PR_FAV_PUBLIC_SOURCE_KEY, lpPropSourceKey);
hr = lpTable->FindRow(lpRestriction, BOOKMARK_BEGINNING, 0);
if (hr != hrSuccess)
goto exit;
// Favorite is exist, get the information
hr = lpTable->QueryRows (1, 0, &lpRows);
if (hr != hrSuccess)
goto exit;
if (lpRows->cRows == 0) {
hr = MAPI_E_NOT_FOUND;
goto exit; // Folder gone?
}
cShortCutValues = 0;
hr = Util::HrCopyPropertyArray(lpRows->aRow[0].lpProps, lpRows->aRow[0].cValues, &lpShortCutPropValues, &cShortCutValues, true);
if (hr != hrSuccess)
goto exit;
*lppShortCutPropValues = lpShortCutPropValues;
*lpcValues = cShortCutValues;
exit:
if (hr != hrSuccess && lpShortCutPropValues)
MAPIFreeBuffer(lpShortCutPropValues);
if (lpPropSourceKey)
MAPIFreeBuffer(lpPropSourceKey);
if (lpTable)
lpTable->Release();
FREE_RESTRICTION(lpRestriction);
return hr;
}
示例3: AddToFavorite
/**
* Add a new favorite in the private store.
*
* @param[in] lpShortcutFolder The shortcut folder in the private store.
* @param[in] ulLevel The depth of the folder, start from one.
* @param[in] lpAliasName Alias name of the folder. Pass NULL to specify the standard foldername
* @param[in] ulFlags possible MAPI_UNICODE for lpszAliasName
* @param[in] cValues Count of property values pointed to by the lpPropArray parameter. The cValues parameter must not be zero.
* @param[in] lpPropArray Pointer to an array of SPropValue structures holding property values to create the favorite.
*/
HRESULT AddToFavorite(IMAPIFolder *lpShortcutFolder, ULONG ulLevel, LPCTSTR lpszAliasName, ULONG ulFlags, ULONG cValues, LPSPropValue lpPropArray)
{
HRESULT hr = hrSuccess;
IMessage *lpMessage = NULL;
LPSPropValue lpPropSourceKey = NULL;
LPSPropValue lpPropParentSourceKey = NULL;
LPSPropValue lpPropDisplayName = NULL;
LPSPropValue lpPropMessageClass = NULL;
LPMAPITABLE lpTable = NULL;
LPSPropValue lpNewPropArray = NULL;
ULONG cPropArray = 0;
LPSRestriction lpRestriction = NULL;
if (lpShortcutFolder == NULL || lpPropArray == NULL) {
hr = MAPI_E_INVALID_PARAMETER;
goto exit;
}
lpPropSourceKey = PpropFindProp(lpPropArray, cValues, PR_SOURCE_KEY);
lpPropParentSourceKey = PpropFindProp(lpPropArray, cValues, PR_PARENT_SOURCE_KEY);
lpPropDisplayName = PpropFindProp(lpPropArray, cValues, PR_DISPLAY_NAME);
lpPropMessageClass = PpropFindProp(lpPropArray, cValues, PR_CONTAINER_CLASS);
if (lpPropSourceKey == NULL || lpPropParentSourceKey == NULL || lpPropDisplayName == NULL)
{
hr = MAPI_E_CORRUPT_DATA;
goto exit;
}
// Check for duplicates
hr = lpShortcutFolder->GetContentsTable(0, &lpTable);
if (hr != hrSuccess)
goto exit;
// build restriction
CREATE_RESTRICTION(lpRestriction);
CREATE_RES_AND(lpRestriction, lpRestriction, 1);
DATA_RES_PROPERTY(lpRestriction, lpRestriction->res.resAnd.lpRes[0], RELOP_EQ, PR_FAV_PUBLIC_SOURCE_KEY, lpPropSourceKey);
if (lpTable->FindRow(lpRestriction, BOOKMARK_BEGINNING , 0) == hrSuccess)
goto exit; // Folder already include
// No duplicate, Start to add the favorite
hr = lpShortcutFolder->CreateMessage(NULL, 0, &lpMessage);
if (hr != hrSuccess)
goto exit;
hr = MAPIAllocateBuffer(sizeof(SPropValue) * 6, (void**)&lpNewPropArray);
if (hr != hrSuccess)
goto exit;
lpNewPropArray[cPropArray].ulPropTag = PR_FAV_LEVEL_MASK;
lpNewPropArray[cPropArray++].Value.ul = ulLevel;
lpNewPropArray[cPropArray].ulPropTag = PR_FAV_PUBLIC_SOURCE_KEY;
lpNewPropArray[cPropArray++].Value = lpPropSourceKey->Value;
lpNewPropArray[cPropArray].ulPropTag = PR_FAV_DISPLAY_NAME;
lpNewPropArray[cPropArray++].Value = lpPropDisplayName->Value;
if (lpPropMessageClass) {
lpNewPropArray[cPropArray].ulPropTag = PR_FAV_CONTAINER_CLASS;
lpNewPropArray[cPropArray++].Value = lpPropMessageClass->Value;
}
if (ulLevel > 1) {
lpNewPropArray[cPropArray].ulPropTag = PR_FAV_PARENT_SOURCE_KEY;
lpNewPropArray[cPropArray++].Value = lpPropParentSourceKey->Value;
}
if (lpszAliasName && lpszAliasName[0] != '\0') {
tstring tDisplay(lpPropDisplayName->Value.LPSZ);
convstring csAlias(lpszAliasName, ulFlags);
if ((std::wstring)csAlias != tDisplay)
{
lpNewPropArray[cPropArray].ulPropTag = (ulFlags & MAPI_UNICODE) ? PR_FAV_DISPLAY_ALIAS_W : PR_FAV_DISPLAY_ALIAS_A;
lpNewPropArray[cPropArray++].Value.lpszA = (LPSTR)lpszAliasName;
}
}
hr = lpMessage->SetProps(cPropArray, lpNewPropArray, NULL);
if (hr != hrSuccess)
goto exit;
hr = lpMessage->SaveChanges(0);
if (hr != hrSuccess)
goto exit;
//.........这里部分代码省略.........
示例4: DelFavoriteFolder
/**
* Remove a favorite in the private store. also the sub favorites will be deleted
*
* @param lpShortcutFolder The shortcut folder in the private store.
* @param lpPropSourceKey Pointer to the sourcekey of a favorite folder
*/
HRESULT DelFavoriteFolder(IMAPIFolder *lpShortcutFolder, LPSPropValue lpPropSourceKey)
{
HRESULT hr = hrSuccess;
LPMAPITABLE lpTable = NULL;
LPSRestriction lpRestriction = NULL;
SRowSet *lpRows = NULL;
LPENTRYLIST lpsMsgList = NULL;
SizedSPropTagArray(2, sPropDelFavo) = {2, { PR_ENTRYID, PR_FAV_PUBLIC_SOURCE_KEY }};
std::list<string> listSourceKey;
std::list<string>::iterator ilistSourceKey;
string strSourceKey;
SPropValue sPropSourceKey;
ULONG ulMaxRows = 0;
if (lpShortcutFolder == NULL || lpPropSourceKey == NULL) {
hr = MAPI_E_INVALID_PARAMETER;
goto exit;
}
hr = lpShortcutFolder->GetContentsTable(0, &lpTable);
if (hr != hrSuccess)
goto exit;
hr = lpTable->GetRowCount(0, &ulMaxRows);
if (hr != hrSuccess)
goto exit;
hr = lpTable->SetColumns((LPSPropTagArray)&sPropDelFavo, 0);
if (hr != hrSuccess)
goto exit;
// build restriction
CREATE_RESTRICTION(lpRestriction);
CREATE_RES_AND(lpRestriction, lpRestriction, 1);
DATA_RES_PROPERTY(lpRestriction, lpRestriction->res.resAnd.lpRes[0], RELOP_EQ, PR_FAV_PUBLIC_SOURCE_KEY, lpPropSourceKey);
if (lpTable->FindRow(lpRestriction, BOOKMARK_BEGINNING , 0) != hrSuccess)
goto exit; // Folder already removed
hr = lpTable->QueryRows (1, 0, &lpRows);
if (hr != hrSuccess)
goto exit;
if (lpRows->cRows == 0)
goto exit; // Folder already removed
hr = MAPIAllocateBuffer(sizeof(ENTRYLIST), (void**)&lpsMsgList);
if (hr != hrSuccess)
goto exit;
hr = MAPIAllocateMore(sizeof(SBinary)*ulMaxRows, lpsMsgList, (void**)&lpsMsgList->lpbin);
if (hr != hrSuccess)
goto exit;
//FIXME: check the properties in the row!!!!
lpsMsgList->cValues = 0;
// add entryid
lpsMsgList->lpbin[lpsMsgList->cValues].cb = lpRows->aRow[0].lpProps[0].Value.bin.cb;
MAPIAllocateMore(lpsMsgList->lpbin[lpsMsgList->cValues].cb, lpsMsgList, (void **) &lpsMsgList->lpbin[lpsMsgList->cValues].lpb);
memcpy(lpsMsgList->lpbin[lpsMsgList->cValues].lpb, lpRows->aRow[0].lpProps[0].Value.bin.lpb, lpsMsgList->lpbin[lpsMsgList->cValues].cb);
lpsMsgList->cValues++;
strSourceKey.assign((char*)lpRows->aRow[0].lpProps[1].Value.bin.lpb, lpRows->aRow[0].lpProps[1].Value.bin.cb);
listSourceKey.push_back(strSourceKey);
if (lpRows){ FreeProws(lpRows); lpRows = NULL; }
FREE_RESTRICTION(lpRestriction);
for(ilistSourceKey = listSourceKey.begin(); ilistSourceKey != listSourceKey.end(); ilistSourceKey++)
{
sPropSourceKey.ulPropTag = PR_FAV_PUBLIC_SOURCE_KEY;
sPropSourceKey.Value.bin.cb = ilistSourceKey->size();
sPropSourceKey.Value.bin.lpb = (LPBYTE)ilistSourceKey->c_str();
CREATE_RESTRICTION(lpRestriction);
CREATE_RES_AND(lpRestriction, lpRestriction, 1);
DATA_RES_PROPERTY(lpRestriction, lpRestriction->res.resAnd.lpRes[0], RELOP_EQ, PR_FAV_PARENT_SOURCE_KEY, &sPropSourceKey);
hr = lpTable->Restrict(lpRestriction, TBL_BATCH );
if (hr != hrSuccess)
goto exit;
hr = lpTable->SeekRow(BOOKMARK_BEGINNING, 0, NULL);
if (hr != hrSuccess)
goto exit;
while(true)
{
hr = lpTable->QueryRows (1, 0, &lpRows);
if (hr != hrSuccess)
//.........这里部分代码省略.........