Registriert seit: 18. Mai 2007
Ort: FDS
108 Beiträge
Delphi 2006 Architect
|
Re: Opendialog, eigene Navigation?
7. Feb 2008, 17:46
so, jetzt eine Version mit auslesen...
Delphi-Quellcode:
uses Registry;
var KeyList : TStrings;
procedure TForm1.Oeffnen1Click(Sender: TObject);
var Filename : String;
begin
SetPlacesBar;
try
if Opendialog1.Execute then
begin
// mach was
end;
finally
ResetPlacesBar;
end;
end;
//*********************************************************************************************************************
function TForm1.ReadKey(Key:String): String;
var Reg : TRegistry;
sHelp : String;
begin
Reg := TRegistry.Create;
Result := '';
try
Reg.RootKey := HKEY_CURRENT_USER;
if Reg.OpenKey('Software\Microsoft\Windows\CurrentVersion\Policies\ComDlg32\Placesbar',false) then
begin
try
sHelp := Reg.ReadString(Key);
except
sHelp := IntToStr(Reg.ReadInteger(Key));
end;
end;
finally
Reg.Free;
end;
Result := sHelp;
end;
//*********************************************************************************************************************
Procedure TForm1.SetPlacesBar;
var Key : String;
i : Integer;
begin
KeyList := TSTringlist.Create;
KeyList.Clear;
for i := 0 to 4 do begin
Key := 'Place'+IntToStr(i);
KeyList.Add(ReadKey(Key));
end;
with TRegistry.Create do
try
RootKey := HKEY_CURRENT_USER;
if OpenKey('Software\Microsoft\Windows\CurrentVersion\Policies\ComDlg32\Placesbar',True) then
begin
WriteString('Place0', 'O:\OFC-FileStorage\FabSources\');
WriteString('Place1', 'O:\Prodator 2\');
WriteString('Place2', 'O:\');
WriteInteger('Place3', 17); //Arbeitsplatz
WriteString('Place4', 'Desktop');
CloseKey;
end;
finally
Free;
end;
end;
//*********************************************************************************************************************
procedure TForm1.ResetPlacesBar;
var i : Integer;
Reg : TRegistry;
Key : String;
begin
Reg := Tregistry.Create;
try
Reg.RootKey := HKEY_CURRENT_USER;
if Reg.OpenKey('Software\Microsoft\Windows\CurrentVersion\Policies\ComDlg32\Placesbar',True) then
begin
for i := 0 to KeyList.count -1 do begin
Key := 'Place'+IntToStr(i);
try
Reg.WriteInteger(Key,StrToInt(KeyList[i]));
except
Reg.WriteString(Key,KeyList[i]);
end;
end;
Reg.CloseKey;
end;
finally
Reg.Free;
KeyList.Free;
end;
end;
//*********************************************************************************************************************
hoffe das die Version jetzt eher den Ansprüchen der Allgemeinheit dient
nehme Verbessungsvorschläge gerne an...
Gruß Ruben
Ruben Theorie ist, wenn man alles weiss, aber nichts funktioniert. Praxis ist, wenn alles funktioniert und keiner weiss warum
|