Mirror

Get outlookexpress directory (Views: 100)


Problem/Question/Abstract:

Did you ever wonder how to retrieve the outlookexpress directory. Down below the answer ..

Answer:

function GetOutlookExpressDir: string;
var
  Reg: TRegistry;
  ts, userID: string;
begin
  ts := '';
  Reg := TRegistry.Create;
  try
    Reg.RootKey := HKEY_CURRENT_USER;
    if Reg.OpenKey('\Software\Microsoft\Outlook Express', False) then
      ts := Reg.ReadString('Store Root');
    if ts = '' then
    begin
      if Reg.OpenKey('\Identities', False) then
      begin
        userID := Reg.ReadString('Default User ID');
        if Reg.OpenKey('\Identities\' + userID +
          '\Software\Microsoft\Outlook Express\5.0', False) then
          ts := Reg.ReadString('Store Root');
      end;
    end;
  finally
    if (ts <> '') then
    begin
      SetLength(userID, 1024);
      if (ExpandEnvironmentStrings(pointer(ts), @userID[1], 1024) > 0) then
        result := pchar(userID)
      else
        result := ts;
    end;
    Reg.CloseKey;
    Reg.Free;
  end;
end;

<< Back to main page