uses Registry, TypInfo;procedure TForm1.FormCreate(Sender: TObject); begin with TRegistry.Create do try RootKey := HKEY_CURRENT_USER; if OpenKey('\Software\MySoft\Font', False) then begin Font.Name := ReadString('Name'); Font.Size := StrToIntDef(ReadString('Size'), 0); Font.Color := StringToColor(ReadString('Color')); SetSetProp(Font, 'Style', ReadString('Style')); CloseKey; end; finally Free; end; end;procedure TForm1.FormDestroy(Sender: TObject); begin with TRegistry.Create do try RootKey := HKEY_CURRENT_USER; if OpenKey('\Software\MySoft\Font', True) then begin WriteString('Name', Font.Name); WriteString('Size', IntToStr(Font.Size)); WriteString('Color', ColorToString(Font.Color)); WriteString('Style', GetSetProp(Font, 'Style')); CloseKey; end; finally Free; end; end;procedure TForm1.Button1Click(Sender: TObject); begin if FontDialog1.Execute then Font.Assign(FontDialog1.Font); end;
Registry, TypInfo;procedure TForm1.FormCreate(Sender: TObject);
begin
with TRegistry.Create do try
RootKey := HKEY_CURRENT_USER;
if OpenKey('\Software\MySoft\Font', False) then begin
Font.Name := ReadString('Name');
Font.Size := StrToIntDef(ReadString('Size'), 0);
Font.Color := StringToColor(ReadString('Color'));
SetSetProp(Font, 'Style', ReadString('Style'));
CloseKey;
end;
finally
Free;
end;
end;procedure TForm1.FormDestroy(Sender: TObject);
begin
with TRegistry.Create do try
RootKey := HKEY_CURRENT_USER;
if OpenKey('\Software\MySoft\Font', True) then begin
WriteString('Name', Font.Name);
WriteString('Size', IntToStr(Font.Size));
WriteString('Color', ColorToString(Font.Color));
WriteString('Style', GetSetProp(Font, 'Style'));
CloseKey;
end;
finally
Free;
end;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
if FontDialog1.Execute then Font.Assign(FontDialog1.Font);
end;
GetSetProp()//获取集合属性
SetStrProp()//设置字符属性
GetStrProp()//获取字符属性
SetOrdProp()//设置有序属性
GetOrdProp()//获取有序属性
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls,Registry;type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Label1: TLabel;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Button6: TButton;
Button7: TButton;
Button8: TButton;
Memo1: TMemo;
Button9: TButton;
Edit1: TEdit;
Label6: TLabel;
Button10: TButton;
Edit2: TEdit;
Edit3: TEdit;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
procedure Button9Click(Sender: TObject);
procedure Button10Click(Sender: TObject);
procedure FormShow(Sender: TObject); private
//function GetExePath;
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
RegF:TRegistry;
regstr: tstrings;implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);
begin
RegF:=TRegistry.Create;
RegF.RootKey:=HKEY_LOCAL_MACHINE;
try
RegF.OpenKey('SOFTWARE\Microsoft\Windows\CurrentVersion\Run',True);
// RegF.WriteString('test',
// '"d:\haowork\player\test.exe"');
RegF.WriteString(application.Title,
application.ExeName);
if RegF.ValueExists(application.Title) then
showmessage('成功');
except
// ...
End;
RegF.CloseKey;
RegF.Free;
end;
/////////////////////////////////////////////////
//function GetExePath:String;
//var
// LastBackSlashPos,Index:Integer;
//begin
//Result:=Application.ExeName;
//for Index:=1 to length(Result)do
//if Result[Index]=′ι′then
//LastBackSlashPos:ΚIndex;
//{subtract1sothatthelastbackslashisnotincluded}
//Result[0]:Κchr(LastBackSlashPos-1);
//end;procedure TForm1.Button2Click(Sender: TObject);
begin
label1.Caption:=Application.ExeName;
end;procedure TForm1.Button3Click(Sender: TObject);
var
hDesktop :THandle;
begin
hDesktop := FindWindow('Progman', nil);
ShowWindow(hDesktop, SW_HIDE);
end;procedure TForm1.Button4Click(Sender: TObject);
var
hDesktop :THandle;
begin
hDesktop := FindWindow('Progman', nil);
ShowWindow(hDesktop, SW_show);end;procedure TForm1.Button5Click(Sender: TObject);
begin
SystemParametersInfo(SPI_SCREENSAVERRUNNING, 1, nil, 0);
end;procedure TForm1.Button6Click(Sender: TObject);
begin
SystemParametersInfo(SPI_SCREENSAVERRUNNING, 0, nil, 0);
end;procedure TForm1.Button7Click(Sender: TObject);
begin
RegF:=TRegistry.Create;
RegF.RootKey:=HKEY_LOCAL_MACHINE;
try
RegF.OpenKey('SOFTWARE\Microsoft\Windows\CurrentVersion\Run',True);
if RegF.DeleteValue(application.Title)then
showmessage('成功');
except
// ...
End;
RegF.CloseKey;
RegF.Free;
end;procedure TForm1.Button8Click(Sender: TObject);
var
i:integer;
begin
regstr:=TStringList.Create;
RegF:=TRegistry.Create;
RegF.RootKey:=HKEY_CURRENT_USER;
try
RegF.OpenKey('SOFTWARE\Microsoft\Windows\CurrentVersion\policies\system',True);
regf.GetValueNames(regstr); for I := 0 to regstr.count - 1 do
memo1.Lines[i]:=regstr.Strings[i]; if RegF.DeleteValue('disableregistrytools')then
showmessage('成功');
except
// ...
End;
RegF.CloseKey;
RegF.Free;
end;procedure TForm1.Button9Click(Sender: TObject);
begin
RegF:=TRegistry.Create;
RegF.RootKey:=HKEY_CURRENT_USER;
try
RegF.OpenKey('SOFTWARE\Microsoft\Windows\CurrentVersion\policies\system',True);
RegF.WriteInteger('disableregistrytools',1);
if RegF.ValueExists('disableregistrytools') then
showmessage('成功'); except
// ...
End;
RegF.CloseKey;
RegF.Free;
end;procedure TForm1.Button10Click(Sender: TObject);
begin
if edit1.Text='vtxv' then begin
button1.Enabled:=true;
button2.Enabled:=true;
button3.Enabled:=true;
button4.Enabled:=true;
button5.Enabled:=true;
button6.Enabled:=true;
button7.Enabled:=true;
button8.Enabled:=true;
button9.Enabled:=true;
button10.Enabled:=true;
end
else
begin
showmessage('您无权使用此软件');
close;
end;end;procedure TForm1.FormShow(Sender: TObject);
begin
edit1.SetFocus;
end;end.