本文整理汇总了C++中LPMAPITABLE::Release方法的典型用法代码示例。如果您正苦于以下问题:C++ LPMAPITABLE::Release方法的具体用法?C++ LPMAPITABLE::Release怎么用?C++ LPMAPITABLE::Release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPMAPITABLE
的用法示例。
在下文中一共展示了LPMAPITABLE::Release方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ComputeSingleFolderSize
ULONGLONG ComputeSingleFolderSize(
_In_ LPMAPIFOLDER lpFolder)
{
HRESULT hRes = S_OK;
LPMAPITABLE lpTable = NULL;
LPSRowSet lpsRowSet = NULL;
SizedSPropTagArray (1, sProps) = { 1, {PR_MESSAGE_SIZE} };
ULONGLONG ullThisFolderSize = 0;
// Look at each item in this folder
WC_MAPI(lpFolder->GetContentsTable(0, &lpTable));
if (lpTable)
{
WC_MAPI(HrQueryAllRows(lpTable, (LPSPropTagArray)&sProps, NULL, NULL, 0, &lpsRowSet));
if (lpsRowSet)
{
for(ULONG i = 0; i < lpsRowSet->cRows; i++)
{
if (PROP_TYPE(lpsRowSet->aRow[i].lpProps[0].ulPropTag) != PT_ERROR)
ullThisFolderSize += lpsRowSet->aRow[i].lpProps[0].Value.l;
}
MAPIFreeBuffer(lpsRowSet);
lpsRowSet = NULL;
}
lpTable->Release();
lpTable = NULL;
}
DebugPrint(DBGGeneric, "Content size = %I64u\n", ullThisFolderSize);
// printf("Content size = %I64d\n", ullThisFolderSize);
WC_MAPI(lpFolder->GetContentsTable(MAPI_ASSOCIATED, &lpTable));
if (lpTable)
{
WC_MAPI(HrQueryAllRows(lpTable, (LPSPropTagArray)&sProps, NULL, NULL, 0, &lpsRowSet));
if (lpsRowSet)
{
for(ULONG i = 0; i < lpsRowSet->cRows; i++)
{
if (PROP_TYPE(lpsRowSet->aRow[i].lpProps[0].ulPropTag) != PT_ERROR)
ullThisFolderSize += lpsRowSet->aRow[i].lpProps[0].Value.l;
}
MAPIFreeBuffer(lpsRowSet);
lpsRowSet = NULL;
}
lpTable->Release();
lpTable = NULL;
}
DebugPrint(DBGGeneric, "Total size = %I64u\n", ullThisFolderSize);
// printf("Total size = %I64d\n", ullThisFolderSize);
return ullThisFolderSize;
} // ComputeSingleFolderSize
示例2: OnRefreshView
// Clear the current list and get a new one with whatever code we've got in LoadMAPIPropList
void CRulesDlg::OnRefreshView()
{
HRESULT hRes = S_OK;
if (!m_lpExchTbl || !m_lpContentsTableListCtrl) return;
if (m_lpContentsTableListCtrl->IsLoading()) m_lpContentsTableListCtrl->OnCancelTableLoad();
DebugPrintEx(DBGGeneric,CLASS,_T("OnRefreshView"),_T("\n"));
if (m_lpExchTbl)
{
LPMAPITABLE lpMAPITable = NULL;
// Open a MAPI table on the Exchange table property. This table can be
// read to determine what the Exchange table looks like.
EC_MAPI(m_lpExchTbl->GetTable(0, &lpMAPITable));
if (lpMAPITable)
{
EC_H(m_lpContentsTableListCtrl->SetContentsTable(
lpMAPITable,
dfDeleted,
NULL));
lpMAPITable->Release();
}
}
} // CRulesDlg::OnRefreshView
示例3: DumpExchangeTable
void DumpExchangeTable(_In_ ULONG ulPropTag, _In_ LPMAPIFOLDER lpFolder)
{
HRESULT hRes = S_OK;
LPEXCHANGEMODIFYTABLE lpExchTbl = NULL;
LPMAPITABLE lpTbl = NULL;
if (lpFolder)
{
// Open the table in an IExchangeModifyTable interface
WC_MAPI(lpFolder->OpenProperty(
ulPropTag,
(LPGUID)&IID_IExchangeModifyTable,
0,
MAPI_DEFERRED_ERRORS,
(LPUNKNOWN*)&lpExchTbl));
if (lpExchTbl)
{
WC_MAPI(lpExchTbl->GetTable(NULL,&lpTbl));
}
if (lpTbl)
{
RegKeys[regkeyDEBUG_TAG].ulCurDWORD |= DBGGeneric;
_OutputTable(DBGGeneric,NULL,lpTbl);
}
}
if (lpTbl) lpTbl->Release();
if (lpExchTbl) lpExchTbl->Release();
} // DumpExchangeTable
示例4: PrintReceiveFolderTable
void PrintReceiveFolderTable(_In_ LPMDB lpMDB)
{
HRESULT hRes = S_OK;
LPMAPITABLE lpReceiveFolderTable = NULL;
WC_MAPI(lpMDB->GetReceiveFolderTable(0, &lpReceiveFolderTable));
if (FAILED(hRes))
{
printf(_T("<receivefoldertable error=0x%x />\n"), hRes);
return;
}
printf(_T("<receivefoldertable>\n"));
if (lpReceiveFolderTable)
{
LPSPropTagArray sTags = (LPSPropTagArray)&sptRECEIVECols;
WC_MAPI(lpReceiveFolderTable->SetColumns(sTags, TBL_ASYNC));
}
if (SUCCEEDED(hRes))
{
LPSRowSet lpRows = NULL;
ULONG iRow = 0;
for (;;)
{
hRes = S_OK;
if (lpRows) FreeProws(lpRows);
lpRows = NULL;
WC_MAPI(lpReceiveFolderTable->QueryRows(
10,
NULL,
&lpRows));
if (FAILED(hRes) || !lpRows || !lpRows->cRows) break;
ULONG i = 0;
for (i = 0; i < lpRows->cRows; i++)
{
printf(_T("<properties index=\"%u\">\n"), iRow);
_OutputProperties(DBGNoDebug, stdout, lpRows->aRow[i].cValues, lpRows->aRow[i].lpProps, NULL, false);
printf(_T("</properties>\n"));
iRow++;
}
}
if (lpRows) FreeProws(lpRows);
}
printf(_T("</receivefoldertable>\n"));
if (lpReceiveFolderTable) { lpReceiveFolderTable->Release(); }
} // PrintReceiveFolderTable
示例5: ExtractContents
void COLAddrFolder::ExtractContents()
{
m_contents.clear();
if (!m_initRef->Inited())
return;
if (!m_pABCont)
return;
LPMAPITABLE pContentTable = NULL;
if (SUCCEEDED(m_pABCont->GetContentsTable(0, &pContentTable)))
{
SizedSPropTagArray ( 4, sptCols ) = {4, PR_DISPLAY_NAME, PR_SMTP_ADDRESS, PR_EMAIL_ADDRESS, PR_ADDRTYPE};
LPSRowSet pRowSet = NULL;
if (SUCCEEDED(g_pMAPIEDK->pHrQueryAllRows(pContentTable, reinterpret_cast<SPropTagArray*>(&sptCols), NULL, NULL, 0, &pRowSet)))
{
m_contents.reserve(pRowSet->cRows);
for (ULONG i = 0; i < pRowSet->cRows; ++i)
{
string addrType;
if (LPSPropValue lpDN = g_pMAPIEDK->pPpropFindProp(pRowSet->aRow[i].lpProps, pRowSet->aRow[i].cValues, PR_ADDRTYPE))
{
addrType = lpDN->Value.lpszA ? lpDN->Value.lpszA : "";
}
if (0 == addrType.compare("SMTP"))
{
if (LPSPropValue lpDN = g_pMAPIEDK->pPpropFindProp(pRowSet->aRow[i].lpProps, pRowSet->aRow[i].cValues, PR_EMAIL_ADDRESS))
{
if (lpDN->Value.lpszA)
m_contents.push_back(lpDN->Value.lpszA);
}
}
else
{
if (LPSPropValue lpDN = g_pMAPIEDK->pPpropFindProp(pRowSet->aRow[i].lpProps, pRowSet->aRow[i].cValues, PR_SMTP_ADDRESS))
{
if (lpDN->Value.lpszA)
m_contents.push_back(lpDN->Value.lpszA);
}
}
}
g_pMAPIEDK->pFreeProws(pRowSet);
}
}
if (pContentTable)
pContentTable->Release();
}
示例6: GetProfiles
void COLAddrBook::GetProfiles(Profiles& profiles)
{
profiles.clear();
LPPROFADMIN pProfAdmin = NULL;
if (SUCCEEDED(g_pMAPIEDK->pMAPIAdminProfiles(0, &pProfAdmin)))
{
LPMAPITABLE pProfTable = NULL;
if (SUCCEEDED(pProfAdmin->GetProfileTable(0, &pProfTable)))
{
SizedSPropTagArray ( 2, sptCols ) = {2, PR_DISPLAY_NAME, PR_DEFAULT_PROFILE};
LPSRowSet pRowSet = NULL;
if (SUCCEEDED(g_pMAPIEDK->pHrQueryAllRows(pProfTable, reinterpret_cast<SPropTagArray*>(&sptCols), NULL, NULL, 0, &pRowSet)))
{
for (ULONG i = 0; i < pRowSet->cRows; ++i)
{
bool bDefaultProfile = false;
if (LPSPropValue pPVN = g_pMAPIEDK->pPpropFindProp(pRowSet->aRow[i].lpProps, pRowSet->aRow[i].cValues, PR_DEFAULT_PROFILE))
{
bDefaultProfile = pPVN->Value.b != 0;
}
if (LPSPropValue pPVN = g_pMAPIEDK->pPpropFindProp(pRowSet->aRow[i].lpProps, pRowSet->aRow[i].cValues, PR_DISPLAY_NAME))
{
profiles.push_back(std::make_pair(pPVN->Value.lpszA ? pPVN->Value.lpszA : "", bDefaultProfile));
}
}
g_pMAPIEDK->pFreeProws(pRowSet);
}
}
if (pProfTable)
pProfTable->Release();
}
if (pProfAdmin)
pProfAdmin->Release();
}
示例7: ProcessAttachments
// This method must be called AFTER the retrieval of the body,
// since the decision if an attachment is embedded or not is made
// based on the body type and contents
void CMapiMessage::ProcessAttachments()
{
LPSPropValue pVal = CMapiApi::GetMapiProperty(m_lpMsg, PR_HASATTACH);
bool hasAttach = true;
if (pVal) {
if (PROP_TYPE(pVal->ulPropTag) == PT_BOOLEAN)
hasAttach = (pVal->Value.b != 0);
CMapiApi::MAPIFreeBuffer(pVal);
}
if (!hasAttach)
return;
// Get the attachment table?
LPMAPITABLE pTable = NULL;
HRESULT hr = m_lpMsg->GetAttachmentTable(0, &pTable);
if (FAILED(hr) || !pTable)
return;
IterateAttachTable(pTable);
pTable->Release();
}
示例8: CheckServerQuota
//.........这里部分代码省略.........
sRestrictProp.Value.lpszA = (char*)lpecCompany->lpszCompanyname;
CREATE_RESTRICTION(lpsRestriction);
CREATE_RES_OR(lpsRestriction, lpsRestriction, 2);
CREATE_RES_NOT(lpsRestriction, &lpsRestriction->res.resOr.lpRes[0]);
DATA_RES_EXIST(lpsRestriction, lpsRestriction->res.resOr.lpRes[0].res.resNot.lpRes[0], PR_EC_COMPANY_NAME_A);
DATA_RES_PROPERTY(lpsRestriction, lpsRestriction->res.resOr.lpRes[1], RELOP_EQ, PR_EC_COMPANY_NAME_A, &sRestrictProp);
hr = lpTable->Restrict(lpsRestriction, MAPI_DEFERRED_ERRORS);
if (hr != hrSuccess) {
m_lpThreadMonitor->lpLogger->Log(EC_LOGLEVEL_FATAL, "Unable to restrict stats table, error 0x%08X", hr);
goto exit;
}
}
while (TRUE) {
hr = lpTable->QueryRows(50, 0, &lpRowSet);
if (hr != hrSuccess) {
m_lpThreadMonitor->lpLogger->Log(EC_LOGLEVEL_FATAL, "Unable to receive stats table data, error 0x%08X", hr);
goto exit;
}
if (lpRowSet->cRows == 0)
break;
for (i = 0; i < lpRowSet->cRows; i++) {
LPSPropValue lpUsername = NULL;
LPSPropValue lpStoreSize = NULL;
LPSPropValue lpQuotaWarn = NULL;
LPSPropValue lpQuotaSoft = NULL;
LPSPropValue lpQuotaHard = NULL;
MsgStorePtr ptrStore;
lpUsername = PpropFindProp(lpRowSet->aRow[i].lpProps, lpRowSet->aRow[i].cValues, PR_EC_USERNAME_A);
lpStoreSize = PpropFindProp(lpRowSet->aRow[i].lpProps, lpRowSet->aRow[i].cValues, PR_MESSAGE_SIZE_EXTENDED);
lpQuotaWarn = PpropFindProp(lpRowSet->aRow[i].lpProps, lpRowSet->aRow[i].cValues, PR_QUOTA_WARNING_THRESHOLD);
lpQuotaSoft = PpropFindProp(lpRowSet->aRow[i].lpProps, lpRowSet->aRow[i].cValues, PR_QUOTA_SEND_THRESHOLD);
lpQuotaHard = PpropFindProp(lpRowSet->aRow[i].lpProps, lpRowSet->aRow[i].cValues, PR_QUOTA_RECEIVE_THRESHOLD);
if (!lpUsername || !lpStoreSize)
continue; // don't log error: could be for several valid reasons (contacts, other server, etc)
if (lpStoreSize->Value.li.QuadPart == 0)
continue;
m_ulProcessed++;
memset(&sQuotaStatus, 0, sizeof(ECQUOTASTATUS));
sQuotaStatus.llStoreSize = lpStoreSize->Value.li.QuadPart;
sQuotaStatus.quotaStatus = QUOTA_OK;
if (lpQuotaHard && lpQuotaHard->Value.ul > 0 && lpStoreSize->Value.li.QuadPart > ((long long)lpQuotaHard->Value.ul * 1024))
sQuotaStatus.quotaStatus = QUOTA_HARDLIMIT;
else if (lpQuotaSoft && lpQuotaSoft->Value.ul > 0 && lpStoreSize->Value.li.QuadPart > ((long long)lpQuotaSoft->Value.ul * 1024))
sQuotaStatus.quotaStatus = QUOTA_SOFTLIMIT;
else if (lpQuotaWarn && lpQuotaWarn->Value.ul > 0 && lpStoreSize->Value.li.QuadPart > ((long long)lpQuotaWarn->Value.ul * 1024))
sQuotaStatus.quotaStatus = QUOTA_WARN;
if (sQuotaStatus.quotaStatus == QUOTA_OK)
continue;
m_lpThreadMonitor->lpLogger->Log(EC_LOGLEVEL_FATAL, "Mailbox of user %s has exceeded its %s limit", lpUsername->Value.lpszA, sQuotaStatus.quotaStatus == QUOTA_WARN ? "warning" : sQuotaStatus.quotaStatus == QUOTA_SOFTLIMIT ? "soft" : "hard");
// find the user in the full users list
for (u = 0; u < cUsers; u++) {
if (strcmp((char*)lpsUserList[u].lpszUsername, lpUsername->Value.lpszA) == 0)
break;
}
if (u == cUsers) {
m_lpThreadMonitor->lpLogger->Log(EC_LOGLEVEL_ERROR, "Unable to find user %s in userlist", lpUsername->Value.lpszA);
m_ulFailed++;
continue;
}
hr = OpenUserStore(lpsUserList[u].lpszUsername, &ptrStore);
if (hr != hrSuccess) {
hr = hrSuccess;
continue;
}
hr = Notify(&lpsUserList[u], lpecCompany, &sQuotaStatus, ptrStore);
if (hr != hrSuccess)
m_ulFailed++;
}
if (lpRowSet)
FreeProws(lpRowSet);
lpRowSet = NULL;
}
exit:
if (lpRowSet)
FreeProws(lpRowSet);
if (lpsRestriction)
MAPIFreeBuffer(lpsRestriction);
if (lpTable)
lpTable->Release();
return hr;
}
示例9: openSpecialFolder
/* open special folder */
bool Mapix::openSpecialFolder(CString folderName, SBinary bin, LPMDB msgStore)
{
LPMAPITABLE table = NULL;
LPMAPIFOLDER m_folder= NULL;
ULONG objectType = NULL;
LPSRowSet pRows = NULL;
result = msgStore->OpenEntry(bin.cb, (LPENTRYID)bin.lpb, NULL, MAPI_MODIFY|MAPI_BEST_ACCESS, &objectType, (LPUNKNOWN*)&m_folder);
if(result != S_OK)
{
setError(result);
return 0;
}
else
{
result = m_folder->GetHierarchyTable(NULL, &table);
if(result == S_OK)
{
const int nProperties = 2;
SizedSPropTagArray(nProperties, Column) = {nProperties, {PR_DISPLAY_NAME, PR_ENTRYID}};
result = table->SetColumns((LPSPropTagArray)&Column, 0);
if(result == S_OK)
{
while(table->QueryRows(1,0, &pRows) == S_OK)
{
if(pRows->cRows != 1)
break;
else
{
CString nameOfFolder( pRows->aRow[0].lpProps[0].Value.lpszW);
if(nameOfFolder == folderName)
{
sBin = pRows->aRow[0].lpProps[1].Value.bin;
m_lpInboxMsgStore = msgStore;
m_folder->Release();
table->Release();
pRows = NULL;
return 1;
}
// open enumarate folder
openSpecialFolder(folderName, pRows->aRow[0].lpProps[1].Value.bin, msgStore);
}
}
}
else
{
setError(result);
return 0;
}
}
else
{
setError(result);
return 0;
}
}
return 0;
}
示例10: 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;
}
示例11: AddFavoriteFolder
/**
* Add new folders to the favorites folder
*
* @param lpSession Pointer to the current mapi session
* @param lpFolder Pointer to a folder in the public store, except a folder from the favorites folder
* @param lpAliasName Pointer to a string containing another name for the folder
* @param ulFlags Bitmask of flags that controls how the folder is added. The following flags can be set:
* FAVO_FOLDER_LEVEL_BASE
* Add only the folder itself
* FAVO_FOLDER_LEVEL_ONE
* Add the folder and the immediate subfolders only
* FAVO_FOLDER_LEVEL_SUB
* Add the folder and all subfolders
* MAPI_UNICODE
* lpAliasName parameter is in wide or multibyte format
*/
HRESULT AddFavoriteFolder(LPMAPIFOLDER lpShortcutFolder, LPMAPIFOLDER lpFolder, LPCTSTR lpAliasName, ULONG ulFlags)
{
HRESULT hr = hrSuccess;
LPMAPITABLE lpTable = NULL;
LPSPropValue lpsPropArray = NULL;
LPSPropValue lpPropDepth = NULL; // No free needed
SRowSet *lpRows = NULL;
ULONG ulFolderFlags = 0;
ULONG cValues = 0;
SizedSPropTagArray(5, sPropsFolderInfo) = {5, { PR_DEPTH, PR_SOURCE_KEY, PR_PARENT_SOURCE_KEY, PR_DISPLAY_NAME, PR_CONTAINER_CLASS}};
// FIXME: check vaiables
// Add folders to the shorcut folder
hr = lpFolder->GetProps((LPSPropTagArray)&sPropsFolderInfo, 0, &cValues, &lpsPropArray);
if (FAILED(hr) != hrSuccess) //Gives always a warning
goto exit;
hr = AddToFavorite(lpShortcutFolder, 1, lpAliasName, ulFlags, cValues, lpsPropArray);
if (hr != hrSuccess)
goto exit;
if (lpsPropArray) { MAPIFreeBuffer(lpsPropArray); lpsPropArray = NULL; }
if (ulFlags == FAVO_FOLDER_LEVEL_SUB) {
ulFolderFlags = CONVENIENT_DEPTH;
} else if(ulFlags == FAVO_FOLDER_LEVEL_ONE) {
ulFolderFlags = 0;
}else {
hr = hrSuccess; // Done
goto exit;
}
// Get subfolders
hr = lpFolder->GetHierarchyTable(ulFolderFlags, &lpTable);
if (hr != hrSuccess)
goto exit;
hr = lpTable->SetColumns((LPSPropTagArray)&sPropsFolderInfo, 0);
if (hr != hrSuccess)
goto exit;
// Add the favorite recusive depended what the flags are
while(true)
{
hr = lpTable->QueryRows (1, 0, &lpRows);
if (hr != hrSuccess)
goto exit;
if (lpRows->cRows == 0)
break;
lpPropDepth = PpropFindProp(lpRows->aRow[0].lpProps,lpRows->aRow[0].cValues, PR_DEPTH);
if (lpPropDepth == NULL) {
hr = MAPI_E_CORRUPT_DATA;// Break the action
goto exit;
}
hr = AddToFavorite(lpShortcutFolder, lpPropDepth->Value.ul + 1, NULL, 0, lpRows->aRow[0].cValues, lpRows->aRow[0].lpProps);
if (hr != hrSuccess) {
// Break the action
goto exit;
}
FreeProws(lpRows);
lpRows = NULL;
} //while(true)
exit:
if (lpTable)
lpTable->Release();
if (lpRows)
FreeProws(lpRows);
if (lpsPropArray)
MAPIFreeBuffer(lpsPropArray);
//.........这里部分代码省略.........
示例12: ConfigMsgService
HRESULT ConfigMsgService(){
HRESULT hr = 0;
LPPROFADMIN lpProfAdmin = NULL;
LPSERVICEADMIN lpServiceAdmin = NULL;
LPMAPITABLE lpMapiTable = NULL;
SRestriction sres; // Restriction structure.
SPropValue SvcProps; // Property structure for restriction.
LPSRowSet lpSvcRows = NULL; // Rowset to hold results of table query.
LPSTR szServer = "155.35.79.109";
LPSTR szMailbox = "InputedBox";
SPropValue rgval[2]; // Property structure to hold values we want to set.
enum { iSvcName, iSvcUID, cptaSvc };
SizedSPropTagArray(cptaSvc, sptCols) = { cptaSvc, PR_SERVICE_NAME, PR_SERVICE_UID };
do{
// if not profile, create profile.
// else use exist profile
DEFINE_IF_HR_NT_OK_BREAK(MAPIAdminProfiles(0, &lpProfAdmin));
LPTSTR strProfileName = L"lhytest";
LPTSTR strProfilePsw = L"123.com";
hr = lpProfAdmin->CreateProfile(strProfileName, NULL, NULL, 0);
if (hr == MAPI_E_NO_ACCESS){
// profile exist;
break;
}
else if (hr == S_OK){
DEFINE_IF_HR_NT_OK_BREAK(lpProfAdmin->AdminServices(strProfileName, NULL, NULL, 0, &lpServiceAdmin));
DEFINE_IF_HR_NT_OK_BREAK(lpServiceAdmin->CreateMsgService((LPTSTR)"MSEMS", NULL, 0, 0));
// todo config MsgService.
hr = lpServiceAdmin->GetMsgServiceTable(0, &lpMapiTable);
DEFINE_IF_HR_NT_OK_BREAK(hr);
sres.rt = RES_CONTENT;
sres.res.resContent.ulFuzzyLevel = FL_FULLSTRING;
sres.res.resContent.ulPropTag = PR_SERVICE_NAME;
sres.res.resContent.lpProp = &SvcProps;
SvcProps.ulPropTag = PR_SERVICE_NAME;
SvcProps.Value.lpszA = "MSEMS";
// Query the table to obtain the entry for the newly created message service.
if (FAILED(hr = HrQueryAllRows(lpMapiTable,
(LPSPropTagArray)&sptCols,
&sres,
NULL,
0,
&lpSvcRows)))
{
break;
}
// Set up a SPropValue array for the properties that you have to configure.
// First, the server name.
ZeroMemory(&rgval[1], sizeof(SPropValue));
rgval[1].ulPropTag = PR_PROFILE_UNRESOLVED_SERVER;
rgval[1].Value.lpszA = szServer;
// Next, the mailbox name.
ZeroMemory(&rgval[0], sizeof(SPropValue));
rgval[0].ulPropTag = PR_PROFILE_UNRESOLVED_NAME;
rgval[0].Value.lpszA = szMailbox;
// Configure the message service by using the previous properties.
if (FAILED(hr = lpServiceAdmin->ConfigureMsgService(
(LPMAPIUID)lpSvcRows->aRow->lpProps[iSvcUID].Value.bin.lpb, // Entry ID of service to configure.
NULL, // Handle to parent window.
0, // Flags.
2, // Number of properties we are setting.
rgval))) // Pointer to SPropValue array.
{
break;
}
}
else {
break;
}
} while (0);
if (lpSvcRows != NULL){
FreeProws(lpSvcRows);
lpSvcRows = NULL;
}
if (lpMapiTable != NULL){
lpMapiTable->Release();
lpMapiTable = NULL;
}
if (lpServiceAdmin != NULL){
lpServiceAdmin->Release();
lpServiceAdmin = NULL;
//.........这里部分代码省略.........
示例13: ComputeFolderSize
ULONGLONG ComputeFolderSize(
_In_z_ LPWSTR lpszProfile,
_In_ LPMAPIFOLDER lpFolder,
_In_ ULONG ulFolder,
_In_z_ LPWSTR lpszFolder)
{
DebugPrint(DBGGeneric,"ComputeFolderSize: Calculating size (including subfolders) for folder %u / %ws from profile %ws \n", ulFolder, lpszFolder?lpszFolder:L"", lpszProfile);
// printf("ComputeFolderSize: Calculating size (including subfolders) for folder %i / %ws from profile %ws \n", ulFolder, lpszFolder?lpszFolder:L"", lpszProfile);
HRESULT hRes = S_OK;
if (lpFolder)
{
LPMAPITABLE lpTable = NULL;
LPSRowSet lpRow = NULL;
ULONG i = 0;
ULONGLONG ullSize = 0;
enum
{
ePR_DISPLAY_NAME_W,
ePR_ENTRYID,
ePR_FOLDER_TYPE,
NUM_COLS
};
static const SizedSPropTagArray(NUM_COLS, rgColProps) =
{
NUM_COLS,
PR_DISPLAY_NAME_W,
PR_ENTRYID,
PR_FOLDER_TYPE,
};
// Size of this folder
ullSize += ComputeSingleFolderSize(lpFolder);
// Size of children
WC_MAPI(lpFolder->GetHierarchyTable(MAPI_DEFERRED_ERRORS, &lpTable));
if (SUCCEEDED(hRes) && lpTable)
{
WC_MAPI(lpTable->SetColumns((LPSPropTagArray)&rgColProps, TBL_ASYNC));
if (!FAILED(hRes)) for (;;)
{
hRes = S_OK;
if (lpRow) FreeProws(lpRow);
lpRow = NULL;
WC_MAPI(lpTable->QueryRows(
50,
NULL,
&lpRow));
if (FAILED(hRes) || !lpRow || !lpRow->cRows) break;
for (i = 0; i < lpRow->cRows; i++)
{
hRes = S_OK;
// Don't look at search folders
if (PR_FOLDER_TYPE == lpRow->aRow[i].lpProps[ePR_FOLDER_TYPE].ulPropTag && FOLDER_SEARCH == lpRow->aRow[i].lpProps[ePR_FOLDER_TYPE].Value.ul)
{
continue;
}
if (PR_ENTRYID == lpRow->aRow[i].lpProps[ePR_ENTRYID].ulPropTag)
{
ULONG ulObjType = NULL;
LPMAPIFOLDER lpSubfolder = NULL;
WC_MAPI(lpFolder->OpenEntry(lpRow->aRow[i].lpProps[ePR_ENTRYID].Value.bin.cb,
(LPENTRYID)lpRow->aRow[i].lpProps[ePR_ENTRYID].Value.bin.lpb,
NULL,
MAPI_BEST_ACCESS,
&ulObjType,
(LPUNKNOWN *) &lpSubfolder));
if (SUCCEEDED(hRes) && lpSubfolder)
{
LPWSTR szDisplayName = L"";
if (PR_DISPLAY_NAME_W == lpRow->aRow[i].lpProps[ePR_DISPLAY_NAME_W].ulPropTag)
{
szDisplayName = lpRow->aRow[i].lpProps[ePR_DISPLAY_NAME_W].Value.lpszW;
}
ullSize += ComputeFolderSize(lpszProfile, lpSubfolder, 0, szDisplayName);
}
if (lpSubfolder) lpSubfolder->Release();
}
}
}
if (lpRow) FreeProws(lpRow);
}
if (lpTable) lpTable->Release();
return ullSize;
}
return 0;
} // ComputeFolderSize
示例14: IterateContents
BOOL CMapiApi::IterateContents( CMapiContentIter *pIter, LPMAPIFOLDER pFolder, ULONG flags)
{
// flags can be 0 or MAPI_ASSOCIATED
// MAPI_ASSOCIATED is usually used for forms and views
HRESULT hr;
LPMAPITABLE lpTable;
hr = pFolder->GetContentsTable( flags, &lpTable);
if (FAILED(hr)) {
MAPI_TRACE2( "GetContentsTable failed: 0x%lx, %d\n", (long)hr, (int)hr);
return( FALSE);
}
ULONG rowCount;
hr = lpTable->GetRowCount( 0, &rowCount);
if (!rowCount) {
MAPI_TRACE0( " Empty Table\n");
}
hr = lpTable->SetColumns( (LPSPropTagArray)&ptaEid, 0);
if (FAILED(hr)) {
lpTable->Release();
MAPI_TRACE2( "SetColumns failed: 0x%lx, %d\n", (long)hr, (int)hr);
return( FALSE);
}
hr = lpTable->SeekRow( BOOKMARK_BEGINNING, 0, NULL);
if (FAILED(hr)) {
lpTable->Release();
MAPI_TRACE2( "SeekRow failed: 0x%lx, %d\n", (long)hr, (int)hr);
return( FALSE);
}
int cNumRows = 0;
LPSRowSet lpRow;
BOOL keepGoing = TRUE;
BOOL bResult = TRUE;
do {
lpRow = NULL;
hr = lpTable->QueryRows( 1, 0, &lpRow);
if(HR_FAILED(hr)) {
MAPI_TRACE2( "QueryRows failed: 0x%lx, %d\n", (long)hr, (int)hr);
bResult = FALSE;
break;
}
if(lpRow) {
cNumRows = lpRow->cRows;
if (cNumRows) {
LPENTRYID lpEID = (LPENTRYID) lpRow->aRow[0].lpProps[ieidPR_ENTRYID].Value.bin.lpb;
ULONG cbEID = lpRow->aRow[0].lpProps[ieidPR_ENTRYID].Value.bin.cb;
ULONG oType = lpRow->aRow[0].lpProps[ieidPR_OBJECT_TYPE].Value.ul;
keepGoing = HandleContentsItem( oType, cbEID, lpEID);
MAPI_TRACE1( " ObjectType: %ld\n", oType);
}
FreeProws( lpRow);
}
} while ( SUCCEEDED(hr) && cNumRows && lpRow && keepGoing);
lpTable->Release();
return( bResult);
}
示例15: RunStoreValidation
HRESULT RunStoreValidation(char* strHost, char* strUser, char* strPass, char *strAltUser, bool bPublic, CHECKMAP checkmap)
{
HRESULT hr = hrSuccess;
LPMAPISESSION lpSession = NULL;
LPMDB lpStore = NULL;
LPMDB lpAltStore = NULL;
LPMDB lpReadStore = NULL;
LPMAPIFOLDER lpRootFolder = NULL;
LPMAPITABLE lpHierarchyTable = NULL;
LPSRowSet lpRows = NULL;
ULONG ulObjectType;
ULONG ulCount;
LPEXCHANGEMANAGESTORE lpIEMS = NULL;
// user
ULONG cbUserStoreEntryID = 0;
LPENTRYID lpUserStoreEntryID = NULL;
wstring strwUsername;
wstring strwAltUsername;
wstring strwPassword;
std::set<std::string> setFolderIgnore;
LPSPropValue lpAddRenProp = NULL;
ULONG cbEntryIDSrc = 0;
LPENTRYID lpEntryIDSrc = NULL;
ECLogger *const lpLogger = new ECLogger_File(EC_LOGLEVEL_FATAL, 0, "-");
hr = MAPIInitialize(NULL);
if (hr != hrSuccess) {
cout << "Unable to initialize session" << endl;
goto exit;
}
// input from commandline is current locale
if (strUser)
strwUsername = convert_to<wstring>(strUser);
if (strPass)
strwPassword = convert_to<wstring>(strPass);
if (strAltUser)
strwAltUsername = convert_to<wstring>(strAltUser);
hr = HrOpenECSession(lpLogger, &lpSession, "zarafa-fsck", PROJECT_SVN_REV_STR, strwUsername.c_str(), strwPassword.c_str(), (const char *)strHost, 0, NULL, NULL);
lpLogger->Release();
if(hr != hrSuccess) {
cout << "Wrong username or password." << endl;
goto exit;
}
if (bPublic) {
hr = HrOpenECPublicStore(lpSession, &lpStore);
if (hr != hrSuccess) {
cout << "Failed to open public store." << endl;
goto exit;
}
} else {
hr = HrOpenDefaultStore(lpSession, &lpStore);
if (hr != hrSuccess) {
cout << "Failed to open default store." << endl;
goto exit;
}
}
if (!strwAltUsername.empty()) {
hr = lpStore->QueryInterface(IID_IExchangeManageStore, (void **)&lpIEMS);
if (hr != hrSuccess) {
cout << "Cannot open ExchangeManageStore object" << endl;
goto exit;
}
hr = lpIEMS->CreateStoreEntryID(L"", (LPTSTR)strwAltUsername.c_str(), MAPI_UNICODE | OPENSTORE_HOME_LOGON, &cbUserStoreEntryID, &lpUserStoreEntryID);
if (hr != hrSuccess) {
cout << "Cannot get user store id for user" << endl;
goto exit;
}
hr = lpSession->OpenMsgStore(0, cbUserStoreEntryID, lpUserStoreEntryID, NULL, MDB_WRITE | MDB_NO_DIALOG | MDB_NO_MAIL | MDB_TEMPORARY, &lpAltStore);
if (hr != hrSuccess) {
cout << "Cannot open user store of user" << endl;
goto exit;
}
lpReadStore = lpAltStore;
} else {
lpReadStore = lpStore;
}
hr = lpReadStore->OpenEntry(0, NULL, &IID_IMAPIFolder, 0, &ulObjectType, (IUnknown **)&lpRootFolder);
if(hr != hrSuccess) {
cout << "Failed to open root folder." << endl;
goto exit;
}
if (HrGetOneProp(lpRootFolder, PR_IPM_OL2007_ENTRYIDS /*PR_ADDITIONAL_REN_ENTRYIDS_EX*/, &lpAddRenProp) == hrSuccess &&
Util::ExtractSuggestedContactsEntryID(lpAddRenProp, &cbEntryIDSrc, &lpEntryIDSrc) == hrSuccess) {
setFolderIgnore.insert(string((const char*)lpEntryIDSrc, cbEntryIDSrc));
}
hr = lpRootFolder->GetHierarchyTable(CONVENIENT_DEPTH, &lpHierarchyTable);
if (hr != hrSuccess) {
cout << "Failed to open hierarchy." << endl;
goto exit;
}
//.........这里部分代码省略.........