求高手给答案(50分)

  • 主题发起人 主题发起人 leo_zzz
  • 开始时间 开始时间
L

leo_zzz

Unregistered / Unconfirmed
GUEST, unregistred user!
我用下面这个方法 将 程序添加到注册表里,让程序开机自动运行

{...

var
RegF:TRegistry;

...

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(shotname,dir); //shotname是程序名 dir是程序地址

except

showmessage('sth wrong has happend!');
End;

RegF.CloseKey;
RegF.Free;

end;}

已经成功,但不知道怎么将写入到注册表 HKEY_LOCALMACHINE/Sodtware/Microsoft/Windows/CurrentVersion/Run
里的程序删掉
例如刚刚写进去的 RegF.WriteString(shotname,dir);

让他不随开机运行

哪位高手能给答案啊?

 
reg.DeleteKey
 
Delphi自带的例子
procedure TForm1.Button1Click(Sender: TObject);
var
Reg: TRegistry;
Val:TStringList;
I:Integer;
begin
Reg:=TRegistry.Create;
try
Val:=TStringList.Create;
try
Reg.RootKey:=HKey_Local_Machine; // Section to look for within the registry
if not Reg.OpenKey(Edit1.Text,False) then
ShowMessage('Error opening key')
else
begin
Reg.GetValueNames(Val);

for I:=0 to Val.Count-1 do
begin
ShowMessage(Edit1.Text + Chr(13) +
'has an Entry Called '+Val.Strings+Chr(13)+
'With a Value of '+Reg.ReadString(Val.Strings));
end;
if MessageDlg('Ok to delete the key and lose all these values?'
,Mtinformation,[mbYes,mbNo],0)=mryes then
Reg.DeleteKey(Edit1.Text);

end;
finally
Val.Free;
end;
finally
Reg.Free;
end;
end;
 
用deletekey函数
 
用deletekey函数

具体一点,给个例子好吗?谢谢
 
With TRegistry.Create do
begin
RootKey:=HKey_Local_Machine;
if OpenKey('/Sodtware/Microsoft/Windows/CurrentVersion/Run
,True)then
begin
if DeleteValue('aa') then //delete key value
showmessage('successful');
CloseKey;
end;
Free;
end;
 
后退
顶部