Some improvements to reg_key_delete() function.
This commit is contained in:
parent
9038b60650
commit
bd9519b60b
@ -83,7 +83,7 @@ namespace MUtils
|
|||||||
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, 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_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_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_key_delete (const reg_root_t &rootKey, const QString &keyName, const bool &recusrive = true, const bool &ascend = false);
|
||||||
MUTILS_API bool reg_enum_values (const reg_root_t &rootKey, const QString &keyName, QStringList &list);
|
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);
|
MUTILS_API bool reg_enum_subkeys(const reg_root_t &rootKey, const QString &keyName, QStringList &list);
|
||||||
}
|
}
|
||||||
|
@ -357,7 +357,27 @@ bool MUtils::Registry::reg_key_exists(const reg_root_t &rootKey, const QString &
|
|||||||
/*
|
/*
|
||||||
* Delete registry key
|
* Delete registry key
|
||||||
*/
|
*/
|
||||||
bool MUtils::Registry::reg_key_delete(const reg_root_t &rootKey, const QString &keyName)
|
bool MUtils::Registry::reg_key_delete(const reg_root_t &rootKey, const QString &keyName, const bool &recusrive, const bool &ascend)
|
||||||
{
|
{
|
||||||
return (SHDeleteKey(registry_root(rootKey), MUTILS_WCHR(keyName)) == ERROR_SUCCESS);
|
bool okay = false;
|
||||||
|
|
||||||
|
if(recusrive)
|
||||||
|
{
|
||||||
|
okay = (SHDeleteKey(registry_root(rootKey), MUTILS_WCHR(keyName)) == ERROR_SUCCESS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
okay = (RegDeleteKey(registry_root(rootKey), MUTILS_WCHR(keyName)) == ERROR_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ascend && okay)
|
||||||
|
{
|
||||||
|
const int pos = qMax(keyName.lastIndexOf(QLatin1Char('/')), keyName.lastIndexOf(QLatin1Char('\\')));
|
||||||
|
if(pos > 0)
|
||||||
|
{
|
||||||
|
reg_key_delete(rootKey, keyName.left(pos), false, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return okay;
|
||||||
}
|
}
|
||||||
|
@ -222,7 +222,7 @@ static void qt_registry_cleanup(void)
|
|||||||
wchar_t key[256];
|
wchar_t key[256];
|
||||||
if(_snwprintf_s(key, 256, _TRUNCATE, KEYS[i], version) > 0)
|
if(_snwprintf_s(key, 256, _TRUNCATE, KEYS[i], version) > 0)
|
||||||
{
|
{
|
||||||
MUtils::Registry::reg_key_delete(MUtils::Registry::root_user, MUTILS_QSTR(key));
|
MUtils::Registry::reg_key_delete(MUtils::Registry::root_user, MUTILS_QSTR(key), true, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user