const char* sub_key = "Software\\demo_cache";
函数定义:
bool SetValue(const std::string& key, const std::string& value) {
HKEY hkey = nullptr;
LSTATUS res = ::RegOpenKeyExA(HKEY_CURRENT_USER, sub_key, 0, KEY_WRITE, &hkey);
if (res != ERROR_SUCCESS) {
res = ::RegCreateKeyA(HKEY_CURRENT_USER, sub_key, &hkey);
}
if (res != ERROR_SUCCESS) {
return false;
}
std::shared_ptr<void> close_key(nullptr, [&](void*) {
if (hkey != nullptr) {
::RegCloseKey(hkey);
hkey = nullptr;

最低0.47元/天 解锁文章
1万+

被折叠的 条评论
为什么被折叠?



