You're opening a key for write access under HKLM (or so you think you are; see next paragraph). This requires elevation. Are you running elevated?
You are calling RegOpenKeyExW() but you are not stating the type of access that you want. This is important: If you want read access, the request can be granted even if you're not running elevated, but if you want write access you need elevation. Passing zero is not giving you a useful handle, if it is giving you one at all! Since you want to set a key value, pass KEY_SET_VALUE to the second-to-last parameter of RegOpenKeyExW().
Another error: You are passing HKEY_LOCAL_MACHINE to RegSetValueExW() when you need to be passing hKey instead (assuming the call to RegOpenKeyExW() succeeds with the right desired access). Also your use of the _T() macro is incorrect because you are explicitly calling for the Unicode version of RegSetValueEx.
Another error: The 3rd parameter to RegSetValueExW() is reserved and must be zero; your code shows it is 3.
Side note: Your buffer size is 1KB, but all you need is 4 bytes. consider changing it to:
1 2 3 4 5
|
DWORD data = <desired value goes here>;
...
if (RegSetValueExW(hKey, L"1083", 0, REG_DWORD, (LPBYTE)&data, sizeof(data)))
...
|
Another error: You pass &lpData when you should have passed lpData, and I don't see anywhere in your code where you initialize the lpData buffer, pressumably with the value you want to write.
After reading the whole thing, I think you are missing a memset() call and I guess your desired value is 3.
EDIT: One more thing. Since this was a question that can only pertain MS Windows, I recommend posting this and other related questions in the Windows Programming forum, not the General C++ forum or any other forum.