outlook配置文件.pst和.ost文件的位置使用MAPI在delphi



有人告诉,如何找到。pst和。ost文件位置为特定的配置文件使用MAPI在Delphi?

代码:

我已经编写了下面的代码来查找. 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

  1. 解析商店条目id:其格式记录在MSDN上-看看OutlookSpy中的PR_STORE_ENTRYID(我是其作者)。

  2. 查看配置文件(IMsgServiceAdmin.GetMsgServiceTable)中的所有服务提供商。对于PR_SERVICE_NAME == 'MSPST MS'/'MSUPST MS'/'INTERSTOR'等服务,读取服务提供商表(IMsgServiceAdmin.AdminProviders),打开配置文件部分,读取PR_ENTRYID。使用IMAPISession::CompareEntryIDs将该条目id与相关存储的条目id进行比较。如果匹配,读取PR_PST_PATH属性。你可以在OutlookSpy中玩这个-点击IMAPISession | AdminServices.

  3. Use Redemption(我也是它的作者)-它暴露了RDOPstStore.PstPathRDOExchangeStore.OstPath

最新更新