设置注册表键值SetRegisterValue

0 0 2025-05-28 本文地址:http://www.pnpon.com/fun/detail-6.html
BOOL SetRegisterValue(HKEY key, CHAR* path, CHAR* name, std::string& strAccessStream)
{
    HKEY hKey = NULL;
    BOOL isok = FALSE;
    do
    {
        long lRet = RegCreateKeyExA(key, path, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS | KEY_WOW64_64KEY, NULL, &hKey, NULL);
        if (ERROR_SUCCESS != lRet)
        {
            break;
        }
        lRet = RegSetValueExA(hKey, name, 0, REG_SZ, (LPBYTE)strAccessStream.c_str(), (ULONG)strAccessStream.size());
        if (ERROR_SUCCESS != lRet)
        {
            break;
        }

        isok = TRUE;
    } while (0);
    if (hKey)
    {
        RegCloseKey(hKey);
    }
    return isok;
}
std::string strAccessStream;
SetRegisterValue(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\MyPath", "UserKey", strAccessStream);
取消
感谢您的支持,我会继续努力的!
扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

您的支持,是我们前进的动力!