this slowpoke moves

Registry Autoload

uses ExtCtrls, Registry, AppEvnts

//

procedure TForm1.FormCreate(Sender: TObject);
begin
 StringGrid1.ColWidths[0]:=200;
 StringGrid1.ColWidths[1]:=480;
 StringGrid1.ColWidths[2]:=150;
end;

procedure TForm1.FormPaint(Sender: TObject);
var
 regini:TreginiFile;
 i:byte;
begin
 StringGrid1.Cols[0].Clear; StringGrid1.Cols[1].Clear;StringGrid1.Cols[2].Clear;
 StringGrid1.RowCount:=2;
 StringGrid1.Cols[0].Add('Name :');
 StringGrid1.Cols[1].Add('Path :');
 StringGrid1.Cols[2].Add('Key :');
  try
   //HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
   regini:=TreginiFile.create();
   regini.rootkey:=HKEY_LOCAL_MACHINE;
   regini.openkey('Software\Microsoft\Windows\CurrentVersion\Run',false);
   regini.GetValueNames(ListBox1.Items);
   regini.closekey;
   regini.openkey('Software\Microsoft\Windows\CurrentVersion',false);
   if ListBox1.Items.Count>0
   then
    for i:=0 to (ListBox1.Items.Count-1) do
     begin
      StringGrid1.RowCount:=StringGrid1.RowCount+1;
      StringGrid1.Cols[0].Add(ListBox1.Items.Strings[i]);
      StringGrid1.Cols[1].Add(regini.ReadString('Run',ListBox1.Items.Strings[i],''));
      StringGrid1.Cols[2].Add('HKEY_LM\Run');
     end;
   regini.closekey;
   //HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
   regini.rootkey:=HKEY_CURRENT_USER;
   regini.openkey('Software\Microsoft\Windows\CurrentVersion\Run',false);
   regini.GetValueNames(ListBox1.Items);
   regini.closekey;
   regini.openkey('Software\Microsoft\Windows\CurrentVersion',false);
   if ListBox1.Items.Count>0
   then
    for i:=0 to (ListBox1.Items.Count-1) do
     begin
      StringGrid1.RowCount:=StringGrid1.RowCount+1;
      StringGrid1.Cols[0].Add(ListBox1.Items.Strings[i]);
      StringGrid1.Cols[1].Add(regini.ReadString('Run',ListBox1.Items.Strings[i],''));
      StringGrid1.Cols[2].Add('HKEY_CU\Run');
     end;
    regini.closekey;
   //HKEY_USERS\.Default\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
   regini.rootkey:=HKEY_USERS;
   regini.openkey('.Default\SOFTWARE\Microsoft\Windows\CurrentVersion\Run',false);
   regini.GetValueNames(ListBox1.Items);
   regini.closekey;
   regini.openkey('.Default\SOFTWARE\Microsoft\Windows\CurrentVersion',false);
   if ListBox1.Items.Count>0
   then
    for i:=0 to (ListBox1.Items.Count-1) do
     begin
      StringGrid1.RowCount:=StringGrid1.RowCount+1;
      StringGrid1.Cols[0].Add(ListBox1.Items.Strings[i]);
      StringGrid1.Cols[1].Add(regini.ReadString('Run',ListBox1.Items.Strings[i],''));
      StringGrid1.Cols[2].Add('HKEY_Users\Run');
     end;
    regini.closekey;
   //HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce
   regini:=TreginiFile.create();
   regini.rootkey:=HKEY_LOCAL_MACHINE;
   regini.openkey('Software\Microsoft\Windows\CurrentVersion\RunOnce',false);
   regini.GetValueNames(ListBox1.Items);
   regini.closekey;
   regini.openkey('Software\Microsoft\Windows\CurrentVersion',false);
   if ListBox1.Items.Count>0
   then
    for i:=0 to (ListBox1.Items.Count-1) do
     begin
      StringGrid1.RowCount:=StringGrid1.RowCount+1;
      StringGrid1.Cols[0].Add(ListBox1.Items.Strings[i]);
      StringGrid1.Cols[1].Add(regini.ReadString('RunOnce',ListBox1.Items.Strings[i],''));
      StringGrid1.Cols[2].Add('HKEY_LM\RunOnce');
     end;
    regini.closekey;
   //HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce
   regini.rootkey:=HKEY_CURRENT_USER;
   regini.openkey('Software\Microsoft\Windows\CurrentVersion\RunOnce',false);
   regini.GetValueNames(ListBox1.Items);
   regini.closekey;
   regini.openkey('Software\Microsoft\Windows\CurrentVersion',false);
   if ListBox1.Items.Count>0
   then
    for i:=0 to (ListBox1.Items.Count-1) do
     begin
      StringGrid1.RowCount:=StringGrid1.RowCount+1;
      StringGrid1.Cols[0].Add(ListBox1.Items.Strings[i]);
      StringGrid1.Cols[1].Add(regini.ReadString('RunOnce',ListBox1.Items.Strings[i],''));
      StringGrid1.Cols[2].Add('HKEY_CU\RunOnce');
     end;
    regini.closekey;
   //HKEY_USERS\.Default\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce
   regini.rootkey:=HKEY_USERS;
   regini.openkey('.Default\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce',false);
   regini.GetValueNames(ListBox1.Items);
   regini.closekey;
   regini.openkey('.Default\SOFTWARE\Microsoft\Windows\CurrentVersion',false);
   if ListBox1.Items.Count>0
   then
    for i:=0 to (ListBox1.Items.Count-1) do
     begin
      StringGrid1.RowCount:=StringGrid1.RowCount+1;
      StringGrid1.Cols[0].Add(ListBox1.Items.Strings[i]);
      StringGrid1.Cols[1].Add(regini.ReadString('RunOnce',ListBox1.Items.Strings[i],''));
      StringGrid1.Cols[2].Add('HKEY_Users\RunOnce');
     end;
    regini.closekey;
   //HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows
   if paramcount>0
   then
    begin
     regini.rootkey:=HKEY_CURRENT_USER;
     regini.openkey('Software\Microsoft\Windows NT\CurrentVersion',false);
     if regini.ReadString('Windows','load','')<>''
     then
      begin
       StringGrid1.RowCount:=StringGrid1.RowCount+1;
       StringGrid1.Cols[0].Add('load');
       StringGrid1.Cols[1].Add(regini.ReadString('Windows','load',''));
       StringGrid1.Cols[2].Add('HKEY_CU\load');
      end;
     regini.CloseKey;
    //HKEY_USERS\.DEFAULT\Software\Microsoft\Windows NT\CurrentVersion\Windows
    regini.rootkey:=HKEY_USERS;
    regini.openkey('.DEFAULT\Software\Microsoft\Windows NT\CurrentVersion',false);
    if regini.ReadString('Windows','load','')<>''
    then
     begin
      StringGrid1.RowCount:=StringGrid1.RowCount+1;
      StringGrid1.Cols[0].Add('load');
      StringGrid1.Cols[1].Add(regini.ReadString('Windows','load',''));
      StringGrid1.Cols[2].Add('HKEY_Users\load');
     end;
    regini.CloseKey;
   end;
   if StringGrid1.RowCount>1
   then StringGrid1.RowCount:=StringGrid1.RowCount-1;
  finally
   regini.free;
  end;
end;

procedure TForm1.StringGrid1KeyDown(Sender: TObject; var Key: Word;  Shift: TShiftState);
var regini:TreginiFile;
begin
 if StringGrid1.Cells[0,0]=''
 then Exit;
 if(key=vk_delete) and (Application.MessageBox(pchar('Delete "'+
                        StringGrid1.Cells[0,StringGrid1.Selection.Top]+
                        '" ?'),'Confirm',MB_OKCANCEL+MB_ICONQUESTION)=1)
 then
  begin
   try
    regini:=TreginiFile.create();
    //
    if(StringGrid1.Cells[2,StringGrid1.Selection.Top]='HKEY_LM\Run') or
      (StringGrid1.Cells[2,StringGrid1.Selection.Top]='HKEY_LM\RunOnce')
    then
    regini.rootkey:=HKEY_LOCAL_MACHINE;
    if(StringGrid1.Cells[2,StringGrid1.Selection.Top]='HKEY_CU\Run') or
      (StringGrid1.Cells[2,StringGrid1.Selection.Top]='HKEY_CU\RunOnce') or
      (StringGrid1.Cells[2,StringGrid1.Selection.Top]='HKEY_CU\load')
    then
    regini.rootkey:=HKEY_CURRENT_USER;
    if(StringGrid1.Cells[2,StringGrid1.Selection.Top]='HKEY_Users\Run') or
      (StringGrid1.Cells[2,StringGrid1.Selection.Top]='HKEY_Users\RunOnce') or
      (StringGrid1.Cells[2,StringGrid1.Selection.Top]='HKEY_Users\load')
    then regini.rootkey:=HKEY_USERS;
    //
    if(StringGrid1.Cells[2,StringGrid1.Selection.Top]='HKEY_LM\Run') or
      (StringGrid1.Cells[2,StringGrid1.Selection.Top]='HKEY_CU\Run')
    then
    regini.openkey('Software\Microsoft\Windows\CurrentVersion\Run',false);
    if(StringGrid1.Cells[2,StringGrid1.Selection.Top]='HKEY_LM\RunOnce') or
      (StringGrid1.Cells[2,StringGrid1.Selection.Top]='HKEY_CU\RunOnce')
    then
    regini.openkey('Software\Microsoft\Windows\CurrentVersion\RunOnce',false);
    if(StringGrid1.Cells[2,StringGrid1.Selection.Top]='HKEY_Users\Run')
    then
    regini.openkey('.Default\SOFTWARE\Microsoft\Windows\CurrentVersion\Run',false);
    if(StringGrid1.Cells[2,StringGrid1.Selection.Top]='HKEY_Users\RunOnce')
    then
    regini.openkey('.Default\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce',false);
    if(StringGrid1.Cells[2,StringGrid1.Selection.Top]='HKEY_CU\load')
    then
    regini.openkey('Software\Microsoft\Windows NT\CurrentVersion\Windows',false);
    if(StringGrid1.Cells[2,StringGrid1.Selection.Top]='HKEY_Users\load')
    then
    regini.openkey('.DEFAULT\Software\Microsoft\Windows NT\CurrentVersion\Windows',false);
    //
    regini.DeleteValue(StringGrid1.Cells[0,StringGrid1.Selection.Top]);
    regini.closekey;
   finally
    regini.free;
   end;
  Form1.FormPaint(Form1);
 end;
end;

Keine Kommentare:

Kommentar veröffentlichen

Beliebte Posts

Translate