int value = 0; HKEY key; RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWAREMyApp", 0, KEY_SET_VALUE, &key); RegSetValueEx(key, L"myKey", NULL, REG_DWORD, (BYTE*)&value, sizeof(value)); RegCloseKey(key);