Форум "Delphi"
Паскаль, Делфи
|
#1 Vlad © 21.05.04 08:24:43
function KeyExists(const Key: String): Boolean; GetValueNames(Strings: TStrings) ну и попробуй открыть kk, если удачно, то проверь существование ключа |
|
#2 pascal 30.04.06 14:06:35
сталкнулся с той-же проблемой, поискал в инэте - нигде не нашёл саомому пришлось писать, за одно и доброе дело сделать решил вот пример: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Registry, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Memo1: TMemo; Edit1: TEdit; Label1: TLabel; Edit2: TEdit; Label2: TLabel; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; Reg: TRegistry; //Vals, Subkeys: TStringList; const EOL =#13 +#10; implementation {$R *.dfm} function FindVals(Key, NeedValue: string): string; var j: Integer; tmpKey, tmpVal, tmpStr: string; DatType: TRegDataType; tmp, tmp2: TStringList; begin if Key[Length(Key)] <> '' then Key:= Key+ ''; Result:= ''; Reg.CloseKey; Reg.OpenKey(Key, False); tmp:= TStringList.Create; tmp2:= TStringList.Create; Reg.GetKeyNames(tmp2); Reg.GetValueNames(tmp); if tmp.Text <> '' then for j:= 0 to tmp.Count-1 do begin tmpVal:= ''; DatType:= Reg.GetDataType(tmp.Strings[j]); if DatType = rdString then begin tmpVal:= Reg.ReadString(tmp.Strings[j]); if tmpVal = NeedValue then Result:= Result+ Key+ tmp.Strings[j] + EOL; end; end; tmp.Clear; Reg.CloseKey; if tmp2.Text <> '' then for j := 0 to tmp2.Count-1 do begin tmpKey := Key+ tmp2.Strings[j]; tmpStr:= FindVals(tmpKey, NeedValue); if tmpStr <> '' then Result:= Result+ tmpStr; tmpStr:= ''; end; tmp2.Clear; tmp.Free; tmp2.Free; end; function ModemPort9x: Byte; var Reg: TRegistry; begin Reg:= TRegistry.Create; Reg.RootKey := HKEY_LOCAL_MACHINE; end; procedure TForm1.Button1Click(Sender: TObject); begin Reg:= TRegistry.Create; Reg.RootKey := HKEY_LOCAL_MACHINE; Memo1.Lines.Text := FindVals(Edit1.Text, Edit2.Text); end; end. ivan-688[собачка]mail[точка]ru |
Написать ответ |
|
