uses Registry;
{ReadStrFormReg Registry}
// 调用 ReadStrFormReg('TEST',Edit1);
procedure WriteStrToReg(SectionStr:string;Edit:TEdit);
var
Reg:TRegistry;
keyName:string;
begin
Reg := TRegistry.Create;
Reg.RootKey := HKEY_LOCAL_MACHINE; {Modify}
keyName := 'SOFTWARE\softReg1'; {Modify}
if Reg.OpenKey(KeyName, True) then
begin
Reg.WriteString(SectionStr,Edit.Text);
Reg.CloseKey;
end;
end;
{ReadStrFormReg Registry}
// 调用 ReadStrFormReg('TEST',Edit1);
procedure ReadStrFormReg(SectionStr:string;Edit:TEdit);
var
Reg:TRegistry;
keyName:string;
begin
Reg := TRegistry.Create;
Reg.RootKey := HKEY_LOCAL_MACHINE; {Modify}
keyName := 'SOFTWARE\softReg1'; {Modify}
if Reg.OpenKey(keyName, True) then
begin
Edit.Text:=Reg.ReadString(SectionStr);
Reg.CloseKey;
end;
Reg.Free;
end;
// 调用 ReadStrFormReg('TEST',Edit1);
procedure WriteStrToReg(SectionStr:string;Edit:TEdit);
var
Reg:TRegistry;
keyName:string;
begin
Reg := TRegistry.Create;
Reg.RootKey := HKEY_LOCAL_MACHINE; {Modify}
keyName := 'SOFTWARE\softReg1'; {Modify}
if Reg.OpenKey(KeyName, True) then
begin
Reg.WriteString(SectionStr,Edit.Text);
Reg.CloseKey;
end;
end;
{ReadStrFormReg Registry}
// 调用 ReadStrFormReg('TEST',Edit1);
procedure ReadStrFormReg(SectionStr:string;Edit:TEdit);
var
Reg:TRegistry;
keyName:string;
begin
Reg := TRegistry.Create;
Reg.RootKey := HKEY_LOCAL_MACHINE; {Modify}
keyName := 'SOFTWARE\softReg1'; {Modify}
if Reg.OpenKey(keyName, True) then
begin
Edit.Text:=Reg.ReadString(SectionStr);
Reg.CloseKey;
end;
Reg.Free;
end;