HKEY Open = 0;
DWORD Created;
DWORD Result;
//Attempt to open the Law Enforcement registry key
Result = RegOpenKeyEx(HKEY_CURRENT_USER,
"LaserShot\\Law Enforce",
0,
KEY_READ,
&Open);
if(Result == ERROR_SUCCESS)
{
//Set the registry subkey value to the current size adjustment
RegSetValueEx(Open,
"SizeAdjustment",
0,
REG_DWORD,
(BYTE *)&SizeAdjustment,
sizeof(DWORD));
}
else
{
//Registry key does not exist. Create it.
Result = RegCreateKeyEx(HKEY_CURRENT_USER,
"LaserShot\\Law Enforce",
0,
"SizeAdjustment",
REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS,
NULL,
&Open,
&Created);
if(Result == ERROR_SUCCESS)
{
RegSetValueEx(Open,
"SizeAdjustment",
0,
REG_DWORD,
(BYTE *)&SizeAdjustment,
sizeof(DWORD));
}
}
//Close registry key
if(Open != 0)
{
RegCloseKey(Open);
}
I've debugged it and stepped through it, and it looks like it executes just fine. However, when I check the registry, the value has not been changed--I still see the original value.
Any ideas what I might be doing wrong? Thanks in advance!
Help setting Registry key
In a game I am writing, the user is able to set various options. I want to be able to save those options in the registry so that the next time they play the game, the selected options will be loaded automatically.
I'm able to read the registry no problem. But on game exit, when I try to save options, the registry key does not appear to be updated. Here is the code I'm using:
What does "RegSetValueEx()" return?
Test to see if this returns an OK or a FAILED return value.. Then we wil lhave more info, and possibly an exact reason to the problem.
www.cppnow.com
Test to see if this returns an OK or a FAILED return value.. Then we wil lhave more info, and possibly an exact reason to the problem.
www.cppnow.com
Interesting--I went back through and checked the return value of RegSetValueEx, and it came back as 5L (Access Denied).
That seems odd, because I''m logged on as the administrator on this machine. I''m able to go into the registry and set the value manually, no problem. Any ideas?
That seems odd, because I''m logged on as the administrator on this machine. I''m able to go into the registry and set the value manually, no problem. Any ideas?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement