WinReg – Windows Registry API
The WinReg API provides a set of functions for interacting with the Windows Registry. It enables applications to create, read, update, and delete registry keys and values.
Key Functions
- RegOpenKeyEx – Opens an existing registry key.
- RegCreateKeyEx – Creates a new registry key or opens an existing one.
- RegCloseKey – Closes an open registry key handle.
- RegQueryValueEx – Retrieves the data for a specified value name associated with an open registry key.
- RegSetValueEx – Sets the data for a value name in an open registry key.
- RegDeleteKey – Deletes a subkey and its values.
- RegEnumKeyEx – Enumerates subkeys of an open registry key.
- RegEnumValue – Enumerates the values for an open registry key.
- RegDeleteValue – Deletes a named value from a registry key.
Typical Usage Pattern
#include <windows.h>
#include <stdio.h>
int main() {
HKEY hKey;
LONG result = RegOpenKeyEx(HKEY_CURRENT_USER,
L"Software\\MyApp",
0,
KEY_READ | KEY_WRITE,
&hKey);
if (result == ERROR_SUCCESS) {
// Read or write values
RegCloseKey(hKey);
} else {
wprintf(L"Failed to open key: %ld\\n", result);
}
return 0;
}