Added reg_key_exists() function.

This commit is contained in:
LoRd_MuldeR 2015-07-26 15:11:17 +02:00
parent 034e8f94f4
commit 6417c49b83
2 changed files with 15 additions and 0 deletions

View File

@ -82,6 +82,7 @@ namespace MUtils
MUTILS_API bool reg_value_write (const reg_root_t &rootKey, const QString &keyName, const QString &valueName, const QString &value);
MUTILS_API bool reg_value_read (const reg_root_t &rootKey, const QString &keyName, const QString &valueName, quint32 &value);
MUTILS_API bool reg_value_read (const reg_root_t &rootKey, const QString &keyName, const QString &valueName, QString &value);
MUTILS_API bool reg_key_exists (const reg_root_t &rootKey, const QString &keyName);
MUTILS_API bool reg_key_delete (const reg_root_t &rootKey, const QString &keyName);
MUTILS_API bool reg_enum_values (const reg_root_t &rootKey, const QString &keyName, QStringList &list);
MUTILS_API bool reg_enum_subkeys(const reg_root_t &rootKey, const QString &keyName, QStringList &list);

View File

@ -340,6 +340,20 @@ bool MUtils::Registry::reg_enum_subkeys(const reg_root_t &rootKey, const QString
return success;
}
/*
* Check registry key existence
*/
bool MUtils::Registry::reg_key_exists(const reg_root_t &rootKey, const QString &keyName)
{
HKEY hKey = NULL;
if(RegOpenKeyEx(registry_root(rootKey), MUTILS_WCHR(keyName), 0, STANDARD_RIGHTS_READ, &hKey) == ERROR_SUCCESS)
{
RegCloseKey(hKey);
return true;
}
return false;
}
/*
* Delete registry key
*/