Excluir chave do registro...não funciona...

Delphi

20/05/2003

Tenho este procedimento para deletar uma chave do registro do windows, mas não funciona...alguém sabe me dizer o que ocorre?

procedure TfPrincipal.acDelExecute(Sender: TObject);
var
Reg : TRegistry;
Dt,Ch: String;
Nr : Integer;
begin
if MessageDlg(´Confirma exclusão do item: ´ + Lv.Items.Item[lv.Selected.Index].Caption
,mtConfirmation,[mbYes,mbNo],0) = mrYes then begin
Dt := cbVrDelphi.Items[cbVrDelphi.ItemIndex];
Reg := TRegistry.Create;
Reg.RootKey := HKEY_CURRENT_USER;
Reg.OpenKey(´Software\Borland\Delphi\´ + Dt + ´\Transfer\´,False);
Case cbVrDelphi.ItemIndex of
0,1 : begin
Nr := Reg.ReadInteger(´Count´);
Dec(Nr);
Reg.WriteInteger(´Count´,Nr);
end;
2..10: begin
Nr := StrToInt(Reg.ReadString(´Count´));
Inc(Nr);
Reg.WriteString(´Count´,IntToStr(Nr));
end;
end;
Ch := ´Software\Borland\Delphi\´ + Dt + ´\Transfer\´;
if Reg.DeleteValue(Ch + ´Title´ + IntToStr(Lv.Selected.Index)) then ShowMessage(´Chave Deletada´);
if Reg.DeleteValue(Ch + ´WorkingDir´ + IntToStr(Lv.Selected.Index)) then ShowMessage(´Chave Deletada´);
if Reg.DeleteValue(Ch + ´Path´ + IntToStr(Lv.Selected.Index)) then ShowMessage(´Chave Deletada´);
if Reg.DeleteValue(Ch + ´Params´ + IntToStr(Lv.Selected.Index)) then ShowMessage(´Chave Deletada´);
Reg.Free;
Lista;
end;
end;


Adriano Santos

Adriano Santos

Curtidas 0

Respostas

Vmotta

Vmotta

20/05/2003

insira essa linha no seu código :

Ch := ´Software\Borland\Delphi\´ + Dt + ´\Transfer\´;

// linha a ser inserida:

Reg.OpenKey(Ch, false);

// continua seu código removendo o Ch dele:

if Reg.DeleteValue(´Title´ + IntToStr(Lv.Selected.Index)) then ShowMessage(´Chave Deletada´);

isso deve resolver, blz ?
t+
Vitor


GOSTEI 0
Adriano Santos

Adriano Santos

20/05/2003

..


GOSTEI 0
POSTAR