Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the diff between RegDeleteKeyValue and RegDeleteValue?

Tags:

winapi

I want to know what is the different between RegDeleteKeyValue and RegDeleteValue in Win32API.

like image 683
Yùjǐn Lín Avatar asked Feb 11 '23 21:02

Yùjǐn Lín


2 Answers

RegDeleteValue() is the legacy function, it has been around for 22 years. RegDeleteKeyValue() was an addition, first available on Vista. Major version 6, you must set the _WIN32_WINNT macro to 0x600 or higher to be able to use it. Won't work on Windows XP, Server 2003 or earlier.

Version 6 altered the behavior of several registry related functions, otherwise without a fantastic documented rationale that I've ever seen. The changes however look like Microsoft tried to make them less easy to exploit by malware. RegDeleteValue() fits, it is quite a dangerous function. Whacking the hKey argument with a buffer overflow, giving it one of the predefined values like HKEY_CURRENT_USER and an attacked program can instantly destroy the user's machine. I think, never tried it :)

So you definitely want to consider RegDeleteKeyValue().

like image 144
Hans Passant Avatar answered Feb 13 '23 12:02

Hans Passant


Both RegDeleteValue and RegDeleteKeyValue remove a value from the Registry. The difference is one of convenience: Applications and system components often structure registry data in groups of subkeys, each holding a list of values. RegDeleteKeyValue allows reuse of the parent key handle when deleting values from several subkeys. With RegDeleteValue you have to open a handle to each subkey individually.

Additional reading:

  • What is the terminology for describing the various parts of the registry?
  • Why do registry keys have a default value?
like image 26
IInspectable Avatar answered Feb 13 '23 12:02

IInspectable