您的位置:首页 > 其它

AdvstringGrid and Registry Demo

2009-07-10 01:56 399 查看
unit regedit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ImgList, Grids, BaseGrid, AdvGrid,registry, asgcheck,
Menus;

type
TForm1 = class(TForm)
AdvStringGrid1: TAdvStringGrid;
ImageList1: TImageList;
Button1: TButton;
Button2: TButton;
PopupMenu1: TPopupMenu;
N1: TMenuItem;
haiou3271: TMenuItem;
N2: TMenuItem;
Label1: TLabel;
Label2: TLabel;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure AdvStringGrid1GetEditorType(Sender: TObject; ACol,
ARow: Integer; var AEditor: TEditorType);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
Reg:TRegistry;
implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var
i:integer;
begin
for i:=0 to 2 do
begin
AdvStringGrid1.Cells[0,0]:='序号';
AdvStringGrid1.Cells[1,0]:='数值名称';
AdvStringGrid1.Cells[2,0]:='数值数据';
AdvStringGrid1.Cells[0,1]:='00';
AdvStringGrid1.Cells[1,1]:='请选择右边注册表项';
//AdvStringGrid1.AddImageIdx(1,1,2,haBeforeText,vatop);
AdvStringGrid1.Alignments[0,i]:=taCenter;
AdvStringGrid1.FontStyles[i,0]:=AdvStringGrid1.FontStyles[i,0]+[fsBold];
AdvStringGrid1.FontColors[i,0]:=clblue;
AdvStringGrid1.FontColors[1,1]:=clred;
end
end;

procedure TForm1.Button1Click(Sender: TObject);
var
i,d:integer;
List:TstringList;
begin
List:=TstringList.Create;
//S:=TstringList.Create;
try
d:=AdvStringGrid1.Combobox.ItemIndex;
Reg:=Tregistry.Create;
Reg.RootKey:=HKEY_LOCAL_MACHINE;
Reg.OpenKey(AdvStringGrid1.Combobox.Items[d],false);
Reg.GetValueNames(List);
for i:=0 to list.Count-1 do
begin
AdvStringGrid1.Cells[0,i+2]:='0'+inttostr(i+1);
AdvStringGrid1.RowCount:=List.Count+2;
AdvStringGrid1.Cells[1,i+2]:=list[i];
AdvStringGrid1.Cells[2,i+2]:=Reg.ReadString(List[i]);
AdvStringGrid1.FontColors[1,i+2]:=Clblue;
AdvStringGrid1.FontColors[2,i+2]:=ClFuchsia;
AdvStringGrid1.Alignments[0,i+2]:=taCenter;
AdvStringGrid1.AddImageIdx(1,i+2,0,haBeforeText,vatop);
AdvStringGrid1.AddImageIdx(2,i+2,1,haBeforeText,vatop);
end
finally
Reg.CloseKey;
Reg.Free;
list.Free;
end
end;

procedure TForm1.Button2Click(Sender: TObject);
var
i:integer;
s:Tstringlist;
begin
s:=Tstringlist.Create;
for i:= 1 to AdvStringGrid1.RowCount do
begin
AdvStringGrid1.Cells[2,i+1]:='';
AdvStringGrid1.Cells[1,i+1]:='';
AdvStringGrid1.AddImageIdx(1,i,255,haBeforeText,vatop);
AdvStringGrid1.AddImageIdx(2,i,255,haBeforeText,vatop);
end
end;

procedure TForm1.AdvStringGrid1GetEditorType(Sender: TObject; ACol,
ARow: Integer; var AEditor: TEditorType);
begin
if (arow = 1) and (acol=2) then
begin
aeditor:= edComboList;
advstringgrid1.Combobox.Clear;
advstringgrid1.AddComboString('SOFTWARE/Microsoft/Windows/CurrentVersion/Run');
advstringgrid1.AddComboString('SOFTWARE/Microsoft/Windows/CurrentVersion/RunOnce');
advstringgrid1.AddComboString('SOFTWARE/Microsoft/Windows/CurrentVersion/RunOnceEx');
end;

end;

end.

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: