又是上次的问题!(10分)

  • 主题发起人 主题发起人 chatop
  • 开始时间 开始时间
C

chatop

Unregistered / Unconfirmed
GUEST, unregistred user!
不知道大家还是否记得我发过这段程序,以前这段程序运行时会出错,但是现在经过
热情的朋友们的帮助已经不会出错了,但随之而来的问题更加严重,注册表中的键值删除
不掉,我也不知道是为什么,请大家帮我看看吧,谢谢了
这是一段:
reg:=tregistry.create;
reg.rootkey:=HKEY_LOCAL_MACHINE;
reg.openkey('Software/Microsoft/Windows/CurrentVersion/RunServices',false);
if bool(reg.readstring('Batterieanzeige'))=true then
begin
if messagebox(0,'发现YAI木马,是否要清除?','病毒提示',MB_yesno+MB_iconquestion)=idyes then
begin
reg.DeleteKey('Batterieanzeige');
flatmemo1.Lines.Add('发现YAI木马,但已被清除');
//reg.CloseKey ;
reg.free;
end
else
flatmemo1.Lines.Add('发现YAI木马,清除工作被用户终止');
//reg.closekey;
//reg.free;
end
else
flatmemo1.lines.add('没有发现YAI木马');
//reg.closekey;
//reg.free;
运行时不会出错,就是删除不掉键值

下面是整个程序。。。


unit Unit1;

interface

uses
; Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
; ExtCtrls, ComCtrls, Menus, StdCtrls, TFlatButtonUnit, TFlatGroupBoxUnit,jpeg,
; TFlatCheckBoxUnit, TFlatPanelUnit, TFlatMemoUnit,registry;

type
; TForm1 = class(TForm)
; ; Panel1: TPanel;
; ; bar: TStatusBar;
; ; Panel2: TPanel;
; ; MainMenu1: TMainMenu;
; ; N1: TMenuItem;
; ; X1: TMenuItem;
; ; Panel3: TPanel;
; ; FlatButton1: TFlatButton;
; ; FlatButton2: TFlatButton;
; ; FlatButton3: TFlatButton;
; ; FlatButton4: TFlatButton;
; ; FlatButton5: TFlatButton;
; ; FlatButton6: TFlatButton;
; ; FlatButton7: TFlatButton;
; ; FlatButton8: TFlatButton;
; ; FlatButton9: TFlatButton;
; ; FlatGroupBox1: TFlatGroupBox;
; ; FlatGroupBox2: TFlatGroupBox;
; ; Timer1: TTimer;
; ; FlatGroupBox3: TFlatGroupBox;
; ; FlatGroupBox4: TFlatGroupBox;
; ; FlatGroupBox5: TFlatGroupBox;
; ; FlatGroupBox6: TFlatGroupBox;
; ; FlatGroupBox7: TFlatGroupBox;
; ; FlatGroupBox8: TFlatGroupBox;
; ; FlatGroupBox9: TFlatGroupBox;
; ; Image1: TImage;
; ; FlatCheckBox1: TFlatCheckBox;
; ; FlatCheckBox2: TFlatCheckBox;
; ; FlatCheckBox3: TFlatCheckBox;
; ; FlatCheckBox5: TFlatCheckBox;
; ; FlatCheckBox6: TFlatCheckBox;
; ; FlatCheckBox7: TFlatCheckBox;
; ; FlatCheckBox8: TFlatCheckBox;
; ; FlatPanel1: TFlatPanel;
; ; FlatCheckBox9: TFlatCheckBox;
; ; FlatCheckBox10: TFlatCheckBox;
; ; FlatCheckBox11: TFlatCheckBox;
; ; FlatCheckBox12: TFlatCheckBox;
; ; FlatCheckBox13: TFlatCheckBox;
; ; FlatMemo1: TFlatMemo;
; ; Label1: TLabel;
; ; procedure FlatButton1Click(Sender: TObject);
; ; procedure FlatButton2Click(Sender: TObject);
; ; procedure Timer1Timer(Sender: TObject);
; ; procedure FlatButton3Click(Sender: TObject);
; ; procedure FormCreate(Sender: TObject);
; ; procedure FlatButton4Click(Sender: TObject);
; ; procedure FlatButton5Click(Sender: TObject);
; ; procedure FlatButton6Click(Sender: TObject);
; ; procedure FlatButton7Click(Sender: TObject);
; ; procedure FlatButton8Click(Sender: TObject);
; ; procedure FlatButton9Click(Sender: TObject);
; private
; ; { Private declarations }
; public
; reg:tregistry; //YAI木马,爱虫病毒
; space:string;
; ; { Public declarations }
; end;

var
; Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FlatButton1Click(Sender: TObject); ;//本机信息
begin

image1.visible:=false;
flatgroupbox1.visible:=true;
flatgroupbox2.visible:=false;
flatgroupbox3.visible:=false;
flatgroupbox4.visible:=false;
flatgroupbox5.visible:=false;
flatgroupbox6.visible:=false;
flatgroupbox7.visible:=false;
flatgroupbox8.visible:=false;
flatgroupbox9.visible:=false;
flatgroupbox1.height:=286;
flatgroupbox1.width:=416;
flatgroupbox1.top:=2;
flatgroupbox1.left:=6;
flatgroupbox1.visible:=true;
bar.Panels.Items[1].Text:= space+'显示出本机的信息以代参考';
end;

procedure TForm1.FlatButton2Click(Sender: TObject); ;//桌面菜单优化
begin
;image1.visible:=false;
;flatgroupbox1.visible:=false;
;flatgroupbox2.visible:=true;
;flatgroupbox3.visible:=false;
;flatgroupbox4.visible:=false;
;flatgroupbox5.visible:=false;
;flatgroupbox6.visible:=false;
;flatgroupbox7.visible:=false;
;flatgroupbox8.visible:=false;
;flatgroupbox9.visible:=false;
;flatgroupbox2.height:=286;
flatgroupbox2.width:=416;
flatgroupbox2.top:=2;
flatgroupbox2.left:=6;
;bar.Panels.Items[1].Text:= space+'桌面菜单的优化有利于更好的使用电脑';

end;

procedure TForm1.Timer1Timer(Sender: TObject); ; ; //状态栏中显示时间
begin
bar.Panels.Items[0].text:='日期:'+ datetostr(now);
panel3.caption:=' '+'Thank You For Use Chatop Software';
end;

procedure TForm1.FlatButton3Click(Sender: TObject); //网络系统优化
begin
image1.visible:=false;
flatgroupbox1.visible:=false;
flatgroupbox2.visible:=false;
flatgroupbox3.visible:=true;
flatgroupbox4.visible:=false;
flatgroupbox5.visible:=false;
flatgroupbox6.visible:=false;
flatgroupbox7.visible:=false;
flatgroupbox8.visible:=false;
flatgroupbox9.visible:=false;
flatgroupbox3.width:=416;
flatgroupbox3.height:=286;
flatgroupbox3.left:=6;
flatgroupbox3.top:=2;
bar.Panels.Items[1].Text:= space+'使您上网的速度大大提升';
end;

procedure TForm1.FormCreate(Sender: TObject); ; ; //状态栏显示文字
begin
image1.left:=16;
image1.height:=281;
image1.top:=8;
image1.width:=401;
space:=' ; ; ; ; ; ; ; ; ';
bar.Panels.Items[1].text:=space+'关于注册表优化!'end;

procedure TForm1.FlatButton4Click(Sender: TObject); ; ;// ; 开机优化
begin
image1.visible:=false;
;flatgroupbox1.visible:=false;
flatgroupbox2.visible:=false;
flatgroupbox3.visible:=false;
flatgroupbox4.visible:=true;
flatgroupbox5.visible:=false;
flatgroupbox6.visible:=false;
flatgroupbox7.visible:=false;
flatgroupbox8.visible:=false;
flatgroupbox9.visible:=false;
flatgroupbox4.width:=416;
flatgroupbox4.height:=286;
flatgroupbox4.left:=6;
flatgroupbox4.top:=2;
bar.Panels.Items[1].Text:= space+'加快开机速度';
end;

procedure TForm1.FlatButton5Click(Sender: TObject);// ;系统安全优化
begin
;image1.visible:=false;
;flatgroupbox1.visible:=false;
flatgroupbox2.visible:=false;
flatgroupbox3.visible:=false;
flatgroupbox4.visible:=false;
flatgroupbox5.visible:=true;
flatgroupbox6.visible:=false;
flatgroupbox7.visible:=false;
flatgroupbox8.visible:=false;
flatgroupbox9.visible:=false;
flatgroupbox5.width:=416;
flatgroupbox5.height:=286;
flatgroupbox5.left:=6;
flatgroupbox5.top:=2;
;bar.Panels.Items[1].Text:= space+'去除系统的不安全隐患';
end;

procedure TForm1.FlatButton6Click(Sender: TObject);//个性设置
begin
; image1.visible:=false;
; flatgroupbox1.visible:=false;
flatgroupbox2.visible:=false;
flatgroupbox3.visible:=false;
flatgroupbox4.visible:=false;
flatgroupbox5.visible:=false;
flatgroupbox6.visible:=true;
flatgroupbox7.visible:=false;
flatgroupbox8.visible:=false;
flatgroupbox9.visible:=false;
flatgroupbox6.width:=416;
flatgroupbox6.height:=286;
flatgroupbox6.left:=6;
flatgroupbox6.top:=2;
bar.Panels.Items[1].Text:= space+'使您的计算机更加个性更加于众不同';
end;

procedure TForm1.FlatButton7Click(Sender: TObject); ;// 安全限制
begin
; ;image1.visible:=false;
; ;flatgroupbox1.visible:=false;
flatgroupbox2.visible:=false;
flatgroupbox3.visible:=false;
flatgroupbox4.visible:=false;
flatgroupbox5.visible:=false;
flatgroupbox6.visible:=false;
flatgroupbox7.visible:=true;
flatgroupbox8.visible:=false;
flatgroupbox9.visible:=false;
flatgroupbox7.width:=416;
flatgroupbox7.height:=286;
flatgroupbox7.left:=6;
flatgroupbox7.top:=2;
bar.Panels.Items[1].Text:= space+'不想让别人使用您的电脑吗?试试这个吧!';
end;

procedure TForm1.FlatButton8Click(Sender: TObject); ;//IE修改精灵
begin
; ;image1.visible:=false;
; ;flatgroupbox1.visible:=false;
flatgroupbox2.visible:=false;
flatgroupbox3.visible:=false;
flatgroupbox4.visible:=false;
flatgroupbox5.visible:=false;
flatgroupbox6.visible:=false;
flatgroupbox7.visible:=false;
flatgroupbox8.visible:=true;
flatgroupbox9.visible:=false;
flatgroupbox8.width:=416;
flatgroupbox8.height:=286;
flatgroupbox8.left:=6;
flatgroupbox8.top:=2;
bar.Panels.Items[1].Text:= space+'去掉讨厌的IE病毒,还IE一个真正的面目';
end;

procedure TForm1.FlatButton9Click(Sender: TObject); //木马克星
//var
; ; ; ;{ Batterieanzeige:string; ;//YAI木马
; ; ; ; MSKernel32:string; ; ; ; //爱虫病毒
; ; ; ; NetSpy:string;//NetSpy木马
; ; ; ; Notepad:string;//backdoor木马 ; }
begin
image1.visible:=false;
flatgroupbox1.visible:=false;
flatgroupbox2.visible:=false;
flatgroupbox3.visible:=false;
flatgroupbox4.visible:=false;
flatgroupbox5.visible:=false;
flatgroupbox6.visible:=false;
flatgroupbox7.visible:=false;
flatgroupbox8.visible:=false;
flatgroupbox9.visible:=true;
flatgroupbox9.width:=416;
flatgroupbox9.height:=286;
flatgroupbox9.left:=6;
flatgroupbox9.top:=2;
bar.Panels.Items[1].Text:= space+'木马克星,克死常见木马';
reg:=tregistry.create;
reg.rootkey:=HKEY_LOCAL_MACHINE;
reg.openkey('Software/Microsoft/Windows/CurrentVersion/RunServices',false);
if bool(reg.readstring('Batterieanzeige'))=true then
begin
if messagebox(0,'发现YAI木马,是否要清除?','病毒提示',MB_yesno+MB_iconquestion)=idyes then
begin
reg.DeleteKey('Batterieanzeige');
flatmemo1.Lines.Add('发现YAI木马,但已被清除');
//reg.CloseKey ;
reg.free;
end
else
flatmemo1.Lines.Add('发现YAI木马,清除工作被用户终止');
//reg.closekey;
//reg.free;
end
else
flatmemo1.lines.add('没有发现YAI木马');
//reg.closekey;
//reg.free;
reg:=tregistry.create;
reg.rootkey:=HKEY_LOCAL_MACHINE;
reg.openkey('Software/Microsoft/Windows/CurrentVersion/Run',false);
if bool(reg.readstring('MSKernel32')) then //判断MSKernel32键值是否存在
begin
if messagebox(0,'发现爱虫木病毒,是否要清除?','病毒提示',MB_yesno+MB_iconquestion)=idyes then
begin
reg.deletekey('MSKernel32');
flatmemo1.lines.add('发现爱虫病毒,但已被清除');
reg.CloseKey ;
reg.free;
end
else
flatmemo1.lines.add('发现爱虫病毒,清除工作被用户终止');
//reg.free;
end
else
flatmemo1.lines.add('没有发现爱虫病毒');
//reg.closekey ;
//reg.free;
reg:=tregistry.create;
reg.rootkey:=HKEY_LOCAL_MACHINE;
reg.openkey('SOFTWARE/Microsoft/Windows/CurrentVersion/Run',false);
if bool(reg.readstring('NetSpy')) then
begin
if messagebox(0,'发现NetSpy木马,是否要清除?','病毒提示',MB_yesno+MB_iconquestion)=idyes then
begin
reg.deletekey('NetSpy');
flatmemo1.Lines.add('发现NetSpy木马,但已被清除');
//reg.closekey ;
reg.free;
end
else
flatmemo1.lines.add('发现NetSpy木马,清除工作被用户终止');
//reg.closekey;
//reg.free;
end
else
flatmemo1.lines.add('没有发现NetSpy木马');
//reg.closekey;
//reg.free;
reg:=tregistry.Create;
reg.rootkey:=HKEY_LOCAL_MACHINE;
reg.openkey('Software/Microsoft/Windows/CurrentVersion/Run',false);
if bool(reg.readstring('Notepad')) then
begin
if messagebox(0,'发现BackDoor木马,是否要清除?','病毒提示',MB_yesno+MB_iconquestion)=idyes then
begin
reg.deletekey('Notepad');
flatmemo1.lines.add('发现BackDoor木马,但已被清除');
//reg.closekey;
reg.free;
end
else
flatmemo1.lines.add('发现BackDoor木马,清除工作被用户终止');
//reg.closekey;
//reg.free;
end
else
flatmemo1.lines.add('没有发现BackDoor木马');
//reg.closekey;
//reg.free;
reg:=tregistry.Create;
reg.rootkey:=HKEY_LOCAL_MACHINE;
reg.openkey('Software/Microsoft/Windows/CurrentVersion/RunServices',false);
if bool(reg.readstring('umgr32.exe')) then
begin
if messagebox(0,'发现BO2000木马,是否要清除?','病毒提示',MB_yesno+MB_iconquestion)=idyes then
begin
reg.deletekey('umgr32.exe');
flatmemo1.lines.add('发现BO2000木马,但已被清除');
//reg.closekey;
reg.free;
end
else
flatmemo1.lines.add('发现BO2000木马,清除工作被用户终止');
//reg.closekey;
//reg.free;
end
else
flatmemo1.lines.add('没有发现BO2000木马');
//reg.closekey;
//reg.free;
end;
end.
我只有10分了,都送给大家吧!
 
你搞错了,把key和value弄混了,在regedit里面,左栏的才是key,右栏的叫value
所以,你要的是 DeleteValue ,而不是 DeleteKey
 
真的好感谢你呀!
问题终于解决了。
对了问你一下:
reg:=tregistry.create;
reg.rootkey:=HKEY_LOCAL_MACHINE;
reg.openkey('Software/Microsoft/Windows/CurrentVersion/RunServices',false);
if bool(reg.readstring('Batterieanzeige'))=true then
begin
if messagebox(0,'发现YAI木马,是否要清除?','病毒提示',MB_yesno+MB_iconquestion)=idyes then
begin
reg.DeleteKey('Batterieanzeige');
flatmemo1.Lines.Add('发现YAI木马,但已被清除');
//reg.CloseKey ;
reg.free;
end
else
flatmemo1.Lines.Add('发现YAI木马,清除工作被用户终止');
//reg.closekey;
//reg.free;
end
else
flatmemo1.lines.add('没有发现YAI木马');
//reg.closekey;
//reg.free;
为什么后面加了reg.closekey;和reg.free;就出错呢?
 
简易不要用 if bool(reg.readstring('Batterieanzeige'))=true 来判断
可以使用: if reg.readstring('Batterieanzeige')<>'' 来判断
 
简易不要用 if bool(reg.readstring('Batterieanzeige'))=true 来判断
可以使用: if reg.readstring('Batterieanzeige')<>'' 来判断

好的!
为什么前面一种不好呢?
 
因为很少人这样用
 
哦,是这样呀,哈哈
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
940
SUNSTONE的Delphi笔记
S
后退
顶部