diff --git a/src/common.c b/src/common.c index d29fbd3..0451de2 100644 --- a/src/common.c +++ b/src/common.c @@ -87,6 +87,19 @@ void reg_close(HKEY key) } } +/* Check if a value exists. + * Returns true on success, false on failure. +*/ +bool reg_check_value(HKEY key, const char *name) +{ + if(key != NULL && RegQueryValueEx(key, name, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) + { + return true; + } + + return false; +} + bool reg_get_bin(HKEY key, const char *name, void *buf, size_t size, const void *default_value) { if(key != NULL) diff --git a/src/common.h b/src/common.h index 85cfef8..f047414 100644 --- a/src/common.h +++ b/src/common.h @@ -45,6 +45,8 @@ HKEY reg_open_main(bool readwrite); HKEY reg_open_subkey(HKEY parent, const char *path, bool readwrite); void reg_close(HKEY key); +bool reg_check_value(HKEY key, const char *name); + bool reg_get_bin(HKEY key, const char *name, void *buf, size_t size, const void *default_value); bool reg_set_bin(HKEY key, const char *name, void *buf, size_t size);