已经有了下述代码,请把终止的代码写出来
注意窗口里面有一个ListView1=========================================================================
var
  reg : TRegistry;
  subreg: TStrings;
  t : TListItem;
begin
      subreg := TStringList.Create;
      Reg := TRegistry.Create;
      Reg.RootKey := HKEY_CURRENT_USER;
      if Reg.OpenKey('\Software\Microsoft\Windows\CurrentVersion\Run',False)
      then begin
        Reg.GetValueNames(subreg);
        for i:=0 to subreg.Count-1 do
        begin
          t := ListView1.Items.Add;
          t.Caption := Reg.ReadString(subreg.Strings[i]);
          t.SubItems.Add('注册表->HKEY_CURRENT_USER->Run');
        end;
      end;      if Reg.OpenKey('\Software\Microsoft\Windows\CurrentVersion\RunServices',False)
      then begin
        Reg.GetValueNames(subreg);
        for i:=0 to subreg.Count-1 do
        begin
          t := ListView2.Items.Add;
          t.Caption := Reg.ReadString(subreg.Strings[i]);
          t.SubItems.Add('注册表->HKEY_CURRENT_USER->RunServices');
        end;
      end;      Reg.RootKey := HKEY_LOCAL_MACHINE;
      if Reg.OpenKey('\Software\Microsoft\Windows\CurrentVersion\Run',False)
      then begin
        Reg.GetValueNames(subreg);
        for i:=0 to subreg.Count-1 do
        begin
          t := ListView1.Items.Add;
          t.Caption := Reg.ReadString(subreg.Strings[i]);
          t.SubItems.Add('注册表->HKEY_LOCAL_MACHINE->Run');
        end;
      end;      if Reg.OpenKey('\Software\Microsoft\Windows\CurrentVersion\RunServices',False)
      then begin
        Reg.GetValueNames(subreg);
        for i:=0 to subreg.Count-1 do
        begin
          t := ListView1.Items.Add;
          t.Caption := Reg.ReadString(subreg.Strings[i]);
          t.SubItems.Add('注册表->HKEY_LOCAL_MACHINE->RunServices');
        end;
      end;
end;

解决方案 »

  1.   

    既然能找到项目窗口的Caption
    用PostMessage(FindWindow(nil,Caption),WM_QUIT,0,0)//WM_QUIT也可用WM_CLOSE
      

  2.   

    请别把我的代码随处乱贴。 ^v^
    下面这些代码和上面是出于同一个程序的,请参考。====================================================================procedure TFrmMain.Button1Click(Sender: TObject);
    var
      reg : TRegistry;
      t : TListItem;
    begin
      if ListView1.SelCount<1 then exit;
      Reg := TRegistry.Create;  try
        t := ListView1.Selected;
        if t.SubItems.Strings[1]='注册表->HKEY_CURRENT_USER->Run'then
        begin
          Reg.RootKey := HKEY_CURRENT_USER;
          Reg.OpenKey('\Software\Microsoft\Windows\CurrentVersion\Run',False);
          Reg.DeleteValue(t.Caption);
        end;    if t.SubItems.Strings[1]='注册表->HKEY_CURRENT_USER->RunServices' then
        begin
          Reg.RootKey := HKEY_CURRENT_USER;
          Reg.OpenKey('\Software\Microsoft\Windows\CurrentVersion\RunServices',False);
          Reg.DeleteValue(t.Caption);
        end;    if t.SubItems.Strings[1]='注册表->HKEY_LOCAL_MACHINE->Run' then
        begin
          Reg.RootKey := HKEY_LOCAL_MACHINE;
          Reg.OpenKey('\Software\Microsoft\Windows\CurrentVersion\Run',False);
          Reg.DeleteValue(t.Caption);
        end;    if t.SubItems.Strings[1]='注册表->HKEY_LOCAL_MACHINE->RunServices' then
        begin
          Reg.RootKey := HKEY_LOCAL_MACHINE;
          Reg.OpenKey('\Software\Microsoft\Windows\CurrentVersion\RunServices',False);
          Reg.DeleteValue(t.Caption);
        end;    t.Delete;
      except
        exit;
      end;
      Reg.Free;
    end;
      

  3.   

    对啦,把 t.SubItems.Strings[1] 改成 t.SubItems.Strings[0] ,不然运行会出错。