unit OperateReg;
interface
uses
; Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,Registry,
; StdCtrls;
type
; TForm1 = class(TForm)
; ; Edit1: TEdit;
; ; Button1: TButton;
; ; Button2: TButton;
; ; procedure Button1Click(Sender: TObject);
; ; procedure Button2Click(Sender: TObject);
; private
; ; { Private declarations }
; public
; ; { Public declarations }
; end;
var
; Form1: TForm1;
implementation
{$R *.DFM}
function WriteRegistry(Name,Value:string):boolean;
var
;registerTemp : TRegistry;
begin
;registerTemp := TRegistry.Create;
;//建立一个Registry实例
;with registerTemp do
; ; begin
; ;RootKey:=HKEY_LOCAL_MACHINE;
; ; //设置根键值为HKEY_LOCAL_MACHINE,找到Software/Microsoft/Windows/CurrentVersion
; ;if OpenKey('Software/Microsoft/Windows/CurrentVersion',True) then
; ;//写入自己程序的快捷方式信息
; ; begin
; ; ; ; ; WriteString(Name,Value);
; ; ; ; ; result := true;
; ; ; ;end
; ; ; else result := false;
; ;//善后处理
// ;CloseKey;
; ;Free;
; ; end;
end;
function DeleteRegistry(Name:String):boolean;
var
;registerTemp : TRegistry;
begin
;registerTemp := TRegistry.Create;
;//建立一个Registry实例
;with registerTemp do
; ; begin
; ;RootKey:=HKEY_LOCAL_MACHINE;
; ; //设置根键值为HKEY_LOCAL_MACHINE/Software/Microsoft/Windows/CurrentVersion
; ;if OpenKey('Software/Microsoft/Windows/CurrentVersion',True) then
; ;//写入自己程序的快捷方式信息
; ; begin
; ; ; ; ; deleteValue(Name);
; ; ; ; ; result := true;
; ; ; ;end
; ; ; else result := false;
; ;//善后处理
; ; // ;CloseKey;
; ;Free;
; ; end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
;If WriteRegistry('taozhiyu','DeDe')
;then
; Begin
; ;Edit1.Text:='Write Registry Successfully!';
; ;Showmessage('See HKEY_LOCAL_MACHINE/Software/Microsoft/Windows/CurrentVersion');
; ;Button2.Enabled:=True;
; ;Button1.Enabled:=False;
; end
;else
; Edit1.Text:='Write Registry Fail!';
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
;If DeleteRegistry('taozhiyu')
;then
;Begin
; Edit1.Text:='Delete Registry Successfully!';
; showmessage('Delete Taozhiyu');
; Button2.Enabled:=False;
;end
;else
; ;Edit1.Text:='Delete Registry Fail!';
end;
end.