Dem Projekt muss eine zweite Form hinzugefügt werden, auf die eine ComboBox, 2 Edit Boxen und zwei Buttons kommen.
Der Editor ist eine einfache Ausführung, kann aber Schlüssel erstellen, löschen oder umbenennen. Mit entsprechender Codeerweiterung ist er in der Lage, alle Funktionen auszuführen.
Das Erstellen oder Löschen von Schlüsseln setzte aber Administratoren Rechte voraus.
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons;
type
TForm2 = class(TForm)
ComboBox1: TComboBox;
Edit1: TEdit;
Edit2: TEdit;
Button1: TBitBtn;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Button2: TBitBtn;
procedure Button1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure ComboBox1KeyPress(Sender: TObject; var Key: Char);
procedure Button2Click(Sender: TObject);
procedure ComboBox1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure FormCreate(Sender: TObject);
procedure Edit2KeyPress(Sender: TObject; var Key: Char);
procedure Edit2Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
changedvalue:boolean;
implementation
{$R *.DFM}
procedure TForm2.FormCreate(Sender: TObject);
begin
ComboBox1.ItemIndex:=0;
end;
procedure TForm2.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
ComboBox1.enabled:=true;
end;
procedure TForm2.ComboBox1KeyPress(Sender: TObject; var Key: Char);
begin
key:=#0;
end;
procedure TForm2.ComboBox1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
key:=0;
end;
procedure TForm2.Button1Click(Sender: TObject);
var intnull,intvalue:integer;
begin
if Edit1.Text='' then begin
MessageDlg('Please enter the value name!',mtInformation,[mbOk],0);
Edit1.SetFocus;
exit;
end;
if (ComboBox1.text='Integer') or (ComboBox1.text='Dword') then begin
val(Edit2.text,intnull,intvalue);
if intvalue <> 0 then begin
Messagedlg('"'+Edit2.text+'" is not a valid integer value!',mtError,[mbOk],0);
Edit2.clear;
Edit2.setfocus;
exit;
end
end;
changedvalue:=true;
Form2.Close;
end;
procedure TForm2.Button2Click(Sender: TObject);
begin
Form2.Close;
end;
procedure TForm2.Edit2KeyPress(Sender: TObject; var Key: Char);
begin
if (ComboBox1.text='Integer') or (ComboBox1.text='Dword') then begin
if key in ['0'..'9',#8] then
else key:=#0;
end
end;
procedure TForm2.Edit2Change(Sender: TObject);
var i:integer;
begin
if (ComboBox1.text='Integer') or (ComboBox1.text='Dword') then begin
for i:=1 to length(Edit2.text) do
if Edit2.text[i] in ['0'..'9',#8] then
else begin Edit2.text:='';break end;
end
end;
end.
Unit1 :
uses Registry, ExtCtrls, ImgList, Menus, IniFiles, Unit2
private
{ Private declarations }
selkey,keytodelonren,datatodelonren:string;
lastkey:array[1..25] of string;
keycount,datacount:integer;
const root_keys:array [0..4] of dword =
(HKEY_CLASSES_ROOT,HKEY_CURRENT_USER,HKEY_LOCAL_MACHINE,HKEY_USERS,
HKEY_CURRENT_CONFIG);
var
Form1: TForm1;
defaultpath : string;
rootkeys : integer;
//
procedure TForm1.FormCreate(Sender: TObject);
var PreviousState:TIniFile;
i,k:integer;
begin
ListView1.Columns.Items[0].width:=ListView1.width-4;
ComboBox1.Width:=ListView1.Width;
if not FileExists(ExtractFilePath(Application.ExeName)+'regedit.ini') then begin
selkey:='';
rootkeys:=2;
keycount:=0;
ComboBox1.text:='Select the rootkey';
sb.Panels.Items[0].text:='My Computer\';
Defaultpath:='My Computer\';
end else begin
PreviousState:=TIniFile.Create(ExtractFilePath(Application.ExeName)+'regedit.ini');
ComboBox1.text:=PreviousState.ReadString('Start','Root','Select the rootkey');
Edit1.text:=PreviousState.ReadString('Start','Path','');
keycount:=PreviousState.ReadInteger('Start','KeyCount',0);
for i:=0 to keycount do
lastkey[i]:=PreviousState.ReadString('Start','Count'+IntToStr(i),'');
PreviousState.Free;
if ComboBox1.Text='Select the rootkey' then exit;
if ComboBox1.text='HKEY_CLASSES_ROOT' then rootkeys:=0
else if ComboBox1.text='HKEY_CURRENT_USER' then rootkeys:=1
else if ComboBox1.text='HKEY_LOCAL_MACHINE' then rootkeys:=2
else if ComboBox1.text='HKEY_USERS' then rootkeys:=3
else if ComboBox1.text='HKEY_CURRENT_CONFIG' then rootkeys:=4;
ComboBox1.Cursor:=crHourglass;
ListView1.Cursor:=crHourglass;
ListView2.Cursor:=crHourglass;
ListView1.Items.BeginUpdate;
ListView1.Items.Clear;
ListView1.Items.EndUpdate;
ListView2.items.BeginUpdate;
ListView2.items.clear;
ListView2.Items.EndUpdate;
GetRegistrykeys(rootkeys,Edit1.text);
GetRegistryData(rootkeys,Edit1.text);
ComboBox1.Cursor:=crdefault;
ListView1.Cursor:=crdefault;
ListView2.Cursor:=crdefault;
Defaultpath:='Mycomputer\'+ComboBox1.text;
sb.Panels.Items[0].text:=Defaultpath+Edit1.text;
end;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
var PreviousState:TIniFile;
i:integer;
begin
PreviousState:=TIniFile.Create(ExtractFilePath(Application.ExeName)+'regedit.ini');
PreviousState.WriteString('Start','Root',ComboBox1.Text);
PreviousState.WriteString('Start','Path',Edit1.text);
PreviousState.WriteInteger('Start','KeyCount',KeyCount);
for i:=0 to keycount do
PreviousState.WriteString('Start','Count'+IntToStr(i),lastkey[i]);
PreviousState.Free;
end;
procedure TForm1.FormResize(Sender: TObject);
begin
ListView1.Columns.Items[0].width:=ListView1.width-22;
ComboBox1.Width:=ListView1.Width
end;
procedure TForm1.ComboBox1Change(Sender: TObject);
var i:integer;
begin
Edit1.text:='';
selkey:='';
ComboBox1.Cursor:=crHourglass;
ListView1.Cursor:=crHourglass;
ListView2.Cursor:=crHourglass;
ListView1.Items.BeginUpdate;
ListView1.Items.Clear;
ListView1.Items.EndUpdate;
ListView2.items.BeginUpdate;
ListView2.items.clear;
ListView2.Items.EndUpdate;
GetRegistryData(ComboBox1.ItemIndex,selkey);
GetRegistrykeys(ComboBox1.ItemIndex,selkey);
ComboBox1.Cursor:=crdefault;
ListView1.Cursor:=crdefault;
ListView2.Cursor:=crdefault;
if ComboBox1.ItemIndex=0 then begin sb.Panels.Items[0].text:='My Computer\HKEY_CLASSES_ROOT';rootkeys:=0 end
else if ComboBox1.ItemIndex=1 then begin sb.Panels.Items[0].text:='My Computer\HKEY_CURRENT_USER';rootkeys:=1 end
else if ComboBox1.ItemIndex=2 then begin sb.Panels.Items[0].text:='My Computer\HKEY_LOCAL_MACHINE';rootkeys:=2 end
else if ComboBox1.ItemIndex=3 then begin sb.Panels.Items[0].text:='My Computer\HKEY_USERS';rootkeys:=3 end
else if ComboBox1.ItemIndex=4 then begin sb.Panels.Items[0].text:='My Computer\HKEY_CURRENT_CONFIG';rootkeys:=4 end;
Defaultpath:=sb.Panels.Items[0].text;
for i:=0 to keycount do lastkey[i]:='';
keycount:=0;
if ListView1.Items.count<>0 then begin
ListView1.Items.Item[0].Selected:=true;
ListView1.Items.Item[0].Focused:=true;
end;
ListView1.SetFocus;
end;
procedure TForm1.PopupMenu2Popup(Sender: TObject);
begin
modify1.Enabled:=ListView2.SelCount<>0;
delete2.Enabled:=ListView2.SelCount<>0;
renamd1.Enabled:=ListView2.SelCount<>0;
end;
procedure TForm1.PopupMenu1Popup(Sender: TObject);
begin
new1.Enabled:=ComboBox1.Text<>'Select the rootkey';
delete1.Enabled:=(ListView1.SelCount<>0) and (ListView1.Selected.Caption<>'<..>');
rename1.Enabled:=(ListView1.SelCount<>0) and (ListView1.Selected.Caption<>'<..>');
end;
{------------------------Utilitys-----------------------------------}
procedure TForm1.ShowRegistryData(name,ndata,datatyp:string);
var p:integer;
begin
with ListView2.items.Add do begin
Caption:=name;
if datatyp='String' then begin imageindex:=2;subitems.Add('String') end
else if datatyp='Dword' then begin imageindex:=3;subitems.Add('Dword') end
else if datatyp='Unknow' then begin imageindex:=4;subitems.Add('Unknow') end
else if datatyp='Binary' then begin imageindex:=3;subitems.Add('Binary') end
else if datatyp='ExpString' then begin imageindex:=2;subitems.Add('ExpString') end;
if ndata='' then ndata:='(Value not set)'
else subitems.Add(ndata);
end
end;
procedure TForm1.GetRegistryData(const rootkey:word;key:string);
var Reg:TRegistry;
datatype:TRegDataType;
valuenames:TStringList;
name,data,datatyp:string;
i:integer;
buffersize,buffer:integer;
begin
reg:=TRegistry.Create;
try
reg.RootKey:=root_keys[rootkey];
reg.OpenKeyReadOnly(key);
try
valuenames := TStringList.Create;
reg.GetValueNames(valuenames);
ListView2.items.BeginUpdate;
ListView2.items.clear;
ListView2.Items.EndUpdate;
for i:=0 to valuenames.Count -1 do begin
name:=valuenames.Strings[i];
datatype:=reg.GetDataType(name);
if datatype = rdString then begin
data:=reg.ReadString(name);
datatyp:='String';
end
else if datatype = rdInteger then begin
data:=inttostr(reg.ReadInteger(name));
datatyp:='Dword';
end
else if datatype = rdExpandString then begin
data:=reg.ReadString(name);
datatyp:='ExpString';
end
else if datatype = rdUnknown then begin
data:='Unknow';
datatyp:='Unknow'
end;
ShowRegistryData(name,data,datatyp);
end;
reg.CloseKey;
valuenames.Free;
finally
reg.free
end
except
reg.free;
exit;
end;
end;
procedure TForm1.GetRegistryKeys(const RootKey:word;Key:string);
var Reg:TRegistry;
KeyNames:TStringList;
i:integer;
begin
Reg := TRegistry.Create;
try
Reg.RootKey := Root_Keys[rootkey];
reg.OpenKeyReadOnly(key);
try
KeyNames:=TStringList.Create;
reg.GetKeyNames(KeyNames);
if Edit1.text<>'' then
with ListView1.Items.Add do begin
caption:='<..>';
imageindex:=1
end;
ListView1.items.BeginUpdate;
for i:=0 to keynames.count-1 do
if keyNames.Strings[i]<>'' then
with ListView1.Items.Add do begin
caption:=keyNames.Strings[i];
if caption<>'..' then imageindex:=0
else imageindex:=1;
end;
ListView1.items.EndUpdate;
reg.CloseKey;
KeyNames.Free;
finally
reg.free
end
except
reg.free;
end
end;
procedure TForm1.Splitter1Moved(Sender: TObject);
begin
ListView1.Columns.Items[0].width:=ListView1.width-22;
ComboBox1.Width:=ListView1.Width;
end;
procedure TForm1.Panel1Resize(Sender: TObject);
begin
ListView1.Columns.Items[0].width:=ListView1.width-22;
ComboBox1.Width:=ListView1.Width
end;
procedure TForm1.RefreshKeys(value:string);
var i,k:integer;
T:TPoint;
begin
ComboBox1.Cursor:=crHourglass;
ListView1.Cursor:=crHourglass;
ListView2.Cursor:=crHourglass;
ListView1.Items.BeginUpdate;
ListView1.Items.Clear;
ListView1.Items.EndUpdate;
GetRegistrykeys(rootkeys,Edit1.text);
ComboBox1.Cursor:=crdefault;
ListView1.Cursor:=crdefault;
ListView2.Cursor:=crdefault;
for i:=0 to ListView1.Items.Count-1 do
if UpperCase(ListView1.Items.Item[i].Caption)=UpperCase(value) then begin
ListView1.Items.Item[i].Selected:=true;
ListView1.Items.Item[i].focused:=true;
k:=i;
break;
end;
T:=ListView1.Items.Item[k].getposition;
ListView1.Scroll(t.x-100,t.y-100);
end;
procedure TForm1.RefreshData(value:string);
var i,k:integer;
T:TPoint;
begin
ComboBox1.Cursor:=crHourglass;
ListView1.Cursor:=crHourglass;
ListView2.Cursor:=crHourglass;
ListView2.items.BeginUpdate;
ListView2.items.clear;
ListView2.Items.EndUpdate;
GetRegistryData(rootkeys,Edit1.text+'\');
ComboBox1.Cursor:=crdefault;
ListView1.Cursor:=crdefault;
ListView2.Cursor:=crdefault;
for i:=0 to ListView2.Items.Count-1 do
if UpperCase(ListView2.Items.Item[i].Caption)=UpperCase(value) then begin
ListView2.Items.Item[i].Selected:=true;
ListView2.Items.Item[i].focused:=true;
k:=i;
break;
end;
T:=ListView2.Items.Item[k].getposition;
ListView2.Scroll(t.x-100,t.y-100);
end;
{-------------------------End Utilitys------------------}
{-------------------------Listview Keys---------------}
procedure TForm1.ListView1DblClick(Sender: TObject);
var sel:TListItem;
p,i,k:integer;
s:string;
T:TPoint;
begin
if ListView1.Items.count=0 then exit;
Sel:=ListView1.selected;
if sel=nil then exit;
selkey:=sel.caption;
if selkey<>'<..>' then begin
Inc(keycount);
lastkey[keycount]:=selkey;
Edit1.text:=Edit1.text+'\'+selkey;
ComboBox1.Cursor:=crHourglass;
ListView1.Cursor:=crHourglass;
ListView2.Cursor:=crHourglass;
ListView1.Items.BeginUpdate;
ListView1.Items.Clear;
ListView1.Items.EndUpdate;
ListView2.items.BeginUpdate;
ListView2.items.clear;
ListView2.Items.EndUpdate;
GetRegistrykeys(rootkeys,Edit1.text);
GetRegistryData(rootkeys,Edit1.text);
ComboBox1.Cursor:=crdefault;
ListView1.Cursor:=crdefault;
ListView2.Cursor:=crdefault;
sb.Panels.Items[0].text:=defaultpath+Edit1.text;
ListView1.Items.Item[0].Selected:=true;
ListView1.Items.Item[0].Focused:=true;
end
else begin
s:=Edit1.text;
p:=lastdelimiter('\',s);
Delete(s,p,length(s));
Edit1.text:=s;
ComboBox1.Cursor:=crHourglass;
ListView1.Cursor:=crHourglass;
ListView2.Cursor:=crHourglass;
ListView1.Items.BeginUpdate;
ListView1.Items.Clear;
ListView1.Items.EndUpdate;
ListView2.items.BeginUpdate;
ListView2.items.clear;
ListView2.Items.EndUpdate;
GetRegistrykeys(rootkeys,Edit1.text);
GetRegistryData(rootkeys,Edit1.text);
ComboBox1.Cursor:=crdefault;
ListView1.Cursor:=crdefault;
ListView2.Cursor:=crdefault;
sb.Panels.Items[0].text:=defaultpath+Edit1.text;
if ListView1.Items.Count<>0 then
for i:=0 to ListView1.Items.Count-1 do
if UpperCase(ListView1.Items.item[i].caption)=UpperCase(lastkey[keycount]) then begin
ListView1.Items.Item[i].Selected:=true;
ListView1.Items.Item[i].Focused:=true;
k:=i;
end;
T:=ListView1.Items.Item[k].getposition;
ListView1.Scroll(t.x-100,t.y-100);
Dec(keycount);
end;
end;
procedure TForm1.ListView1KeyPress(Sender: TObject; var Key: Char);
var i:integer;
s:string;
begin
if key=#13 then ListView1dblclick(nil)
end;
procedure TForm1.ListView1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var T:TPoint;
click:TListView;
begin
if (button=mbRight) and (ComboBox1.Text<>'Select the rootkey') then
begin
GetCursorPos(T);
PopupMenu1.popup(T.x,T.y);
end;
end;
procedure TForm1.New1Click(Sender: TObject);
var value:string;
input:boolean;
Reg:TRegistry;
begin
value := 'New key';
input := inputquery('Create key','Name:',value);
if input then begin
try
Reg:=TRegistry.Create;
Reg.RootKey:=Root_Keys[rootkeys];
reg.OpenKey(Edit1.text+'\',false);
if reg.KeyExists(value) then begin
Messagedlg('The specified key already exists!',mtInformation,[mbOk],0);
exit;
end;
reg.CreateKey(value);
reg.CloseKey;
reg.free;
RefreshKeys(value);
except
Messagedlg('Cannot create registry key!',mterror,[mbOk],0);
reg.free;
end;
end
end;
procedure TForm1.delete1Click(Sender: TObject);
var Reg:TRegistry;
s:string;
begin
if ListView1.selected.Caption='<..>' then exit;
s:=ListView1.Selected.Caption;
if MessageDlg('Are you sure you want to delete the key "'+s+'" and all of its subkeys?',
mtConfirmation,[mbYes,mbNo],0)=mrNo then exit;
Reg := TRegistry.Create;
try
Reg.RootKey := Root_Keys[rootkeys];
reg.DeleteKey(Edit1.text+'\'+s);
ComboBox1.Cursor:=crHourglass;
ListView1.Cursor:=crHourglass;
ListView2.Cursor:=crHourglass;
ListView1.Items.BeginUpdate;
ListView1.Items.Clear;
ListView1.Items.EndUpdate;
ListView2.items.BeginUpdate;
ListView2.items.clear;
ListView2.Items.EndUpdate;
GetRegistrykeys(rootkeys,Edit1.text);
GetRegistryData(rootkeys,Edit1.text);
ComboBox1.Cursor:=crdefault;
ListView1.Cursor:=crdefault;
ListView2.Cursor:=crdefault;
ListView1.Items.Item[0].Selected:=true;
ListView1.Items.Item[0].Focused:=true;
Reg.Free;
except
Messagedlg('Cannot delete registry key',mterror,[mbOk],0);
Reg.Free;
end;
end;
procedure TForm1.rename1Click(Sender: TObject);
var value,newvalue:string;
input:boolean;
Reg:TRegistry;
begin
if ListView1.selected.Caption='<..>' then exit;
value:=ListView1.Selected.Caption;
input := inputquery('Rename key','New name:',newvalue);
if input then begin
try
if UpperCase(newvalue)=UpperCase(value) then exit;
Reg:=TRegistry.Create;
Reg.RootKey:=Root_Keys[rootkeys];
reg.OpenKey(Edit1.text+'\',false);
if reg.KeyExists(newvalue) then begin
Messagedlg('The specified key already exists!',mtInformation,[mbOk],0);
exit;
end;
reg.DeleteKey(value);
reg.CreateKey(newvalue);
reg.CloseKey;
reg.free;
RefreshKeys(newvalue);
except
Messagedlg('Cannot rename registry key!',mterror,[mbOk],0);
reg.free;
end;
end
end;
{---------------------End Listview Keys-----------------------}
{--------------------Listview Data(value)----------------------}
procedure TForm1.ListView2MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var T:TPoint;
begin
try
if (button=mbRight) and (ComboBox1.Text<>'Select the rootkey') then begin
GetCursorPos(T);
PopupMenu1.popup(T.x,T.y);
end
except
exit
end;
end;
procedure TForm1.New2Click(Sender: TObject);
var Reg:TRegistry;
begin
changedvalue:=false;
with Form2 do begin
caption:='Create value';
Edit1.Text:='';
Edit2.text:='';
Edit1.Enabled:=true;
Edit2.Enabled:=true;
ComboBox1.enabled := true;
showModal;
if changedvalue then begin
try
Reg:=TRegistry.Create;
Reg.RootKey := Root_Keys[rootkeys];
reg.OpenKey(Edit1.text,false);
if ComboBox1.Text='String' then
reg.WriteString(Edit1.Text,Edit2.text)
else if ComboBox1.Text='Expandable string' then
reg.WriteExpandString(Edit1.Text,Edit2.text)
else if (ComboBox1.Text='Integer') or (ComboBox1.Text='Dword') then
reg.WriteInteger(Edit1.Text,StrToIntDef(Edit2.text,0));
reg.CloseKey;
reg.free;
RefreshData(Edit1.text);
except
Messagedlg('Cannot create registry value!',mterror,[mbOk],0);
reg.free;
end;
end;
end;
end;
procedure TForm1.Delete2Click(Sender: TObject);
var Reg:TRegistry;
selkey,seldata:string;
begin
selData:=ListView2.Selected.Caption;
if MessageDlg('Are you sure you want to delete the value "'+seldata+'"?',
mtConfirmation,[mbYes,mbNo],0)=mrNo then exit;
Reg := TRegistry.Create;
try
Reg.RootKey := Root_Keys[rootkeys];
reg.OpenKey(Edit1.text,false);
Reg.DeleteValue(seldata);
reg.CloseKey;
reg.free;
except
Messagedlg('Cannot delete registry value',mterror,[mbOk],0);
reg.free;
end;
ComboBox1.Cursor:=crHourglass;
ListView1.Cursor:=crHourglass;
ListView2.Cursor:=crHourglass;
GetRegistryData(rootkeys,Edit1.text+'\'+selkey);
ComboBox1.Cursor:=crdefault;
ListView1.Cursor:=crdefault;
ListView2.Cursor:=crdefault;
end;
procedure TForm1.Renamd1Click(Sender: TObject);
var Reg:TRegistry;
i:integer;
oldname:string;
begin
changedvalue:=false;
with Form2 do begin
caption:='Rename value';
oldname:=ListView2.Selected.Caption;
try
Edit1.Text:=ListView2.selected.Caption;
Edit2.Text:=ListView2.selected.SubItems.Strings[1];
except
end;
if UpperCase(ListView2.selected.SubItems.Strings[0])='STRING' then
ComboBox1.ItemIndex:=0
else if UpperCase(ListView2.selected.SubItems.Strings[0])='EXPANDABLE STRING' then
ComboBox1.ItemIndex:=1
else if UpperCase(ListView2.selected.SubItems.Strings[0])='INTEGER' then
ComboBox1.ItemIndex:=2
else if UpperCase(ListView2.selected.SubItems.Strings[0])='DWORD' then
ComboBox1.ItemIndex:=3;
Edit1.Enabled:=true;
Edit2.Enabled:=false;
ComboBox1.enabled:=false;
Edit1.SelectAll;
showModal;
if changedvalue then begin
try
if oldname=Edit1.Text then exit;
Reg:=TRegistry.Create;
Reg.RootKey := Root_Keys[rootkeys];
reg.OpenKey(Edit1.text,false);
Reg.RenameValue(oldname,Edit1.text);
reg.CloseKey;
reg.free;
RefreshData(Edit1.text);
except
Messagedlg('Cannot rename registry value!',mterror,[mbOk],0);
reg.free;
end;
end;
end;
end;
procedure TForm1.Modify1Click(Sender: TObject);
var Reg:TRegistry;
buffersize:integer;
begin
buffersize:=2048;
changedvalue:=false;
with Form2 do begin
caption:='Modify value';
try
Edit1.Text:=ListView2.selected.Caption;
Edit2.Text:=ListView2.selected.SubItems.Strings[1];
except
end;
if UpperCase(ListView2.selected.SubItems.Strings[0])='STRING' then
ComboBox1.ItemIndex:=0
else if UpperCase(ListView2.selected.SubItems.Strings[0])='EXPANDABLE STRING' then
ComboBox1.ItemIndex:=1
else if UpperCase(ListView2.selected.SubItems.Strings[0])='INTEGER' then
ComboBox1.ItemIndex:=2
else if UpperCase(ListView2.selected.SubItems.Strings[0])='DWORD' then
ComboBox1.ItemIndex:=3;
Edit1.Enabled:=false;
Edit2.Enabled:=true;
ComboBox1.enabled:=false;
Edit2.SelectAll;
showModal;
if changedvalue then begin
try
Reg:=TRegistry.Create;
Reg.RootKey := Root_Keys[rootkeys];
reg.OpenKey(Edit1.text,false);
if ComboBox1.Text='String' then
reg.WriteString(Edit1.Text,Edit2.text)
else if ComboBox1.Text='Expandable string' then
reg.WriteExpandString(Edit1.Text,Edit2.text)
else if (ComboBox1.Text='Integer') or (ComboBox1.Text='Dword') then
reg.WriteInteger(Edit1.Text,StrToIntDef(Edit2.text,0));
reg.CloseKey;
reg.free;
RefreshData(Edit1.text);
except
Messagedlg('Cannot modify registry value!',mterror,[mbOk],0);
reg.free;
end;
end;
end;
end;
Keine Kommentare:
Kommentar veröffentlichen