如何获取 Delphi 项目 MRU 列表?
How to get the Delphi Projects MRU List?
我正在尝试从特定 Delphi 版本获取项目 MRU 列表:
function GetDelphiMRUList(const verstr: string; var MRUList: TStringList): Boolean;
var
Reg: TRegistry;
begin
Result := False;
MRUList.Text := '';
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_CURRENT_USER;
Reg.OpenKeyReadOnly('SOFTWARE\Embarcadero\BDS\' + verstr);
Result := Reg.KeyExists('Closed Projects');
Reg.CloseKey;
if Result then
begin
// How to get the MRUList?
end;
finally
Reg.Free;
end;
end;
用法:
procedure TForm1.FormCreate(Sender: TObject);
begin
var MRUList: TStringList;
MRUList := TStringList.Create;
try
if GetDelphiMRUList('22.0', MRUList) then
CodeSite.Send('TForm1.FormCreate: MRUList', MRUList);
finally
MRUList.Free;
end;
end;
我无法获取已关闭项目的列表。
至少在我的系统上,注册表值被命名为 File_0
、File_1
等,因此检索此列表很容易:
function GetDelphiMRUList(const verstr: string; MRUList: TStringList): Boolean;
begin
var Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_CURRENT_USER;
Result := Reg.OpenKey('SOFTWARE\Embarcadero\BDS\' + verstr + '\Closed Projects', False);
if Result then
begin
MRUList.Clear;
var i := 0;
while Reg.ValueExists('File_' + i.ToString) do
begin
MRUList.Add(Reg.ReadString('File_' + i.ToString));
Inc(i);
end;
end;
finally
Reg.Free;
end;
end;
(请注意,让 MRUList
成为 var
参数没有意义。)
用法:
procedure TForm1.FormCreate(Sender: TObject);
begin
var List := TStringList.Create;
try
if GetDelphiMRUList('21.0', List) then
Memo1.Lines.Assign(List)
else
Memo1.Text := 'Couldn''t get MRU list.';
finally
List.Free;
end;
end;
我正在尝试从特定 Delphi 版本获取项目 MRU 列表:
function GetDelphiMRUList(const verstr: string; var MRUList: TStringList): Boolean;
var
Reg: TRegistry;
begin
Result := False;
MRUList.Text := '';
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_CURRENT_USER;
Reg.OpenKeyReadOnly('SOFTWARE\Embarcadero\BDS\' + verstr);
Result := Reg.KeyExists('Closed Projects');
Reg.CloseKey;
if Result then
begin
// How to get the MRUList?
end;
finally
Reg.Free;
end;
end;
用法:
procedure TForm1.FormCreate(Sender: TObject);
begin
var MRUList: TStringList;
MRUList := TStringList.Create;
try
if GetDelphiMRUList('22.0', MRUList) then
CodeSite.Send('TForm1.FormCreate: MRUList', MRUList);
finally
MRUList.Free;
end;
end;
我无法获取已关闭项目的列表。
至少在我的系统上,注册表值被命名为 File_0
、File_1
等,因此检索此列表很容易:
function GetDelphiMRUList(const verstr: string; MRUList: TStringList): Boolean;
begin
var Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_CURRENT_USER;
Result := Reg.OpenKey('SOFTWARE\Embarcadero\BDS\' + verstr + '\Closed Projects', False);
if Result then
begin
MRUList.Clear;
var i := 0;
while Reg.ValueExists('File_' + i.ToString) do
begin
MRUList.Add(Reg.ReadString('File_' + i.ToString));
Inc(i);
end;
end;
finally
Reg.Free;
end;
end;
(请注意,让 MRUList
成为 var
参数没有意义。)
用法:
procedure TForm1.FormCreate(Sender: TObject);
begin
var List := TStringList.Create;
try
if GetDelphiMRUList('21.0', List) then
Memo1.Lines.Assign(List)
else
Memo1.Text := 'Couldn''t get MRU list.';
finally
List.Free;
end;
end;