【发布时间】:2014-08-24 12:30:18
【问题描述】:
有人告诉我如何在 Delphi 中使用 MAPI 查找特定配置文件的 .PST 和 .OST 文件位置吗?
代码:
我编写了以下代码来查找 .PST 路径。但我在“HrgetoneProps”行中收到错误“2147221233”
FMapiSession := nil;
res := MAPILogonEx(0, 'Default Outlook Profile', nil, ulFlags, FMapiSession);
if res = S_OK then
begin
res := MAPIAdminProfiles(0, ProfAdmin);
{$IFDEF DEBUG}CodeSite.Send('MAPIAdminProfiles'); {$ENDIF}
if res = S_OK then
begin
res := FMapiSession.AdminServices(0, ServAdmin);
if res = S_OK then
begin
res := ServAdmin.GetMsgServiceTable(0, Tbl);
if res = S_OK then
begin
res := Tbl.SetColumns(PSPropTagArray(@sptCols), 0);
if res = S_OK then
begin
sres.rt := RES_PROPERTY;
sres.res.resProperty.relop := RELOP_EQ;
sres.res.resProperty.ulPropTag := PR_SERVICE_NAME;
sres.res.resProperty.lpProp := @spv;
spv.ulPropTag := PR_SERVICE_NAME;
spv.Value.lpszA := 'MSUPST MS';
res := HrQueryAllRows(Tbl, @sptCols, @sres, nil, 0, pRow);
if res = S_OK then
begin
for I := 0 to pRow.aRow[0].cValues - 1 do
begin
if (pRow.aRow[0].lpProps[I].ulPropTag = PR_SERVICE_UID) then
begin
MsgStoreUID := PMAPIUID(pRow.aRow[0].lpProps[I].Value.bin.lpb);
break;
end;
end;
res := ServAdmin.OpenProfileSection(MsgStoreUID, TGUID(nil^),
MAPI_Force_ACCESS or MAPI_MODIFY, ProfSect);
if res = S_OK then
begin
{$IFDEF DEBUG}CodeSite.Send('HrGetOneProp'); {$ENDIF}
res := HrGetOneProp(ProfSect, PR_PST_PATH, propVal);
if res = S_OK then
begin
Result := propVal^.Value.lpszA;
MAPIFreeBuffer(propVal);
end
end
else
begin
// ...
end;
FreePRows(pRow);
end;
end;
end;
end;
end;
end
【问题讨论】:
标签: delphi outlook-2010 mapi