HKEY hKey = nullptr;
if (RegCreateKeyExW(
HKEY_CURRENT_USER,
L"Software\\MyApp",
0,
nullptr,
REG_OPTION_NON_VOLATILE,
KEY_WRITE,
nullptr,
&hKey,
nullptr) == ERROR_SUCCESS) {
const std::wstring ver = L"2.0";
RegSetValueExW(
hKey,
L"Version",
0,
REG_SZ,
reinterpret_cast<const BYTE*>(ver.c_str()),
static_cast<DWORD>(
(ver.size() + 1) * sizeof(wchar_t)
)
);
RegCloseKey(hKey);
}