There are several issues with your code (using legacy APIs, using bad parameters, missing logic, etc).
Try something more like this instead:
#include <iostream>
#include <Windows.h>
const DWORD transparenton = 0x00000001;
const DWORD transparentoff = 0x00000000;
using namespace std;
void pause();
void act(HKEY key);
bool getTransparency(HKEY key, DWORD &value);
void setTransparency(HKEY key, DWORD value);
int main()
{
cout << "\tStart Menu Blurrier\n";
cout << "Make your Windows 10 start menu background blurry like in Windows 7\nAutomatic On/Off\n";
pause();
HKEY hKey;
LONG result = RegOpenKeyExW(HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", 0, KEY_QUERY_VALUE | KEY_SET_VALUE, &hKey);
if (result == 0)
{
act(hKey);
RegCloseKey(hKey);
}
return 0;
}
void pause()
{
cout << "Press [ENTER] to continue...";
cin.get();
system("cls");
}
void act(HKEY key)
{
DWORD value;
if (getTransparency(key, value))
{
if (value == transparenton) {
setTransparency(key, transparentoff);
}
else {
setTransparency(key, transparenton);
}
}
}
bool getTransparency(HKEY key, DWORD &value)
{
DWORD size = sizeof(value);
LONG result = RegQueryValueExW(key, L"EnableBlurBehind", NULL, NULL, (BYTE*)&value, &size);
if (result == ERROR_FILE_NOT_FOUND)
{
value = transparentoff;
result = 0;
}
return (result == 0);
}
void setTransparency(HKEY key, DWORD value)
{
RegSetValueExW(key, L"EnableBlurBehind", 0, REG_DWORD, (BYTE*)&value, sizeof(value));
}
2
solved Unexplainable bug in my code