I am writing a program to add parameters to the registry, but it wouldn’t be anything, everything works, then I run an antivirus and access to the registry through the program was closed and I have an exception -

Project Project1.exe raised exception class ERegistry with message 'Failed to set data for' HungAppTimeout '. Process Stopped. Use Step or Run to continue.

How to handle an exception with the output of a message about the impossibility of adding a parameter help, I did not understand the floor of the Internet.

Here is the source:

**{ TRegistry *reg=new TRegistry; reg->RootKey=HKEY_CURRENT_USER; reg->OpenKey("\Control Panel\\Desktop",true); // Навернека строковый параметр reg->WriteString("AutoEndTasks", 2); // Auto closed programm reg->CloseKey(); Application->MessageBox("Параметр добавлен, значение 2 ", "Registry", MB_OK | MB_ICONINFORMATION); delete reg; exit; }** 
  • Perhaps the answer remained in the other half, which you did not climb - DreamChild
  • I read how to handle an exception when copying a file, then what about the files does not fit the registry .... - Arsenty Suvorov
  • one
    @KoVadim: I wonder how you can insert the Russian text, so that it is spoiled? Is that the browser is to blame. - VladD
  • one
    You can, if it has a 64 bit system, the browser is also, and the builder is old, 32bit. True, there is one old trick - before copying the text, you need to switch to Russian, and when inserting into the browser, also to Russian. @Programmist Syvorov, yes, slash! in the line "\Control Panel\\Desktop" \ C means something completely different. It must be either "Control Panel\\Desktop" or "\\Control Panel\\Desktop" . But my comment will be ignored again. - KoVadim
  • 2
    @Programmist Syvorov: indeed, correct the slashes, the chances that it will solve at least a piece of the problem are very high. - VladD

1 answer 1

like that:

 TRegistry *reg=new TRegistry; try { try { reg->RootKey=HKEY_CURRENT_USER; reg->OpenKey("\Control Panel\\Desktop",true); // Íàâåðíåêà ñòðîêîâûé ïàðàìåòð reg->WriteString("AutoEndTasks", 2); // Auto closed programm reg->CloseKey(); Application->MessageBox("Ïàðàìåòð äîáàâëåí, çíà÷åíèå 2 ", "Registry", MB_OK | MB_ICONINFORMATION); } catch(...) { Application->MessageBox("Шеф, всё пропало!!!", "Кабздец", MB_OK | MB_ICONSTOP); } } __finally { delete reg; }