下面的东东是我学习的时候用,不知对你有没有帮助:(仔细看Button1Click这个事件)
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls,registry;
type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Label1: TLabel;
Button4: TButton;
procedure Button1Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
var
reg:TRegistry;
procedure TForm1.Button1Click(Sender: TObject);
begin
reg:=tregistry.create;
with reg do
begin
RootKey:=HKEY_LOCAL_MACHINE;
if not reg.KeyExists('Software/Microsoft/Windows/CurrentVersion/lyfkey'+edit1.text) then
begin
if application.messagebox('this key is not exesit,create it now? if you want to create it press enter ','ask to how to continue',MB_OKCANCEL)=idok then
begin
if reg.CreateKey('Software/Microsoft/Windows/CurrentVersion/lyfkey'+edit1.text) then
showmessage('create sussefull!!!');
end;
end
else
showmessage('the key'+' '+''''+edit1.text+''''+' '+' already exsit yet');
end;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
close;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
label1.top:=form1.Height -label1.Height-40 ;
label1.Left :=0;
label1.width:=form1.Width-50;
end;
end.