E
elitecodex
Hey everyone. I have a function that reads in a registry value (for
the windows firewall) and one that disables it.
Reading the value works perfectly. However, I am getting an access
denied error when trying to set the value. Here is the body of the
function
HKEY hkeyFirewall;
if ( RegOpenKeyEx(HKEY_LOCAL_MACHINE, registryLocations[0], 0,
KEY_WRITE | KEY_READ, &hkeyFirewall) != ERROR_SUCCESS)
wxLogError("FAILED - Could not open the firewall policy registry
entry");
else
{
if ( RegSetValueEx(hkeyFirewall, "EnableFirewall", 0, REG_DWORD,
(BYTE*)0, sizeof(DWORD)) != ERROR_SUCCESS )
{
ErrorString("DisableWindowsFirewall()");
wxLogError("FAILED - Could not set the EnableFirewall value");
}
RegCloseKey(hkeyFirewall);
}
The error is in RegSetValue. It returns "Access denied". ErrorString
is almost taken completely out of the PlatformSDK which is how Im
getting the error.
I've also tried opening the key with KEY_ALL_ACCESS and KEY_SET_VALUE
in combination with KEY_WRITE | KEY_READ as you see above.
Any ideas? The user is in the Administrator group. Thanks!
the windows firewall) and one that disables it.
Reading the value works perfectly. However, I am getting an access
denied error when trying to set the value. Here is the body of the
function
HKEY hkeyFirewall;
if ( RegOpenKeyEx(HKEY_LOCAL_MACHINE, registryLocations[0], 0,
KEY_WRITE | KEY_READ, &hkeyFirewall) != ERROR_SUCCESS)
wxLogError("FAILED - Could not open the firewall policy registry
entry");
else
{
if ( RegSetValueEx(hkeyFirewall, "EnableFirewall", 0, REG_DWORD,
(BYTE*)0, sizeof(DWORD)) != ERROR_SUCCESS )
{
ErrorString("DisableWindowsFirewall()");
wxLogError("FAILED - Could not set the EnableFirewall value");
}
RegCloseKey(hkeyFirewall);
}
The error is in RegSetValue. It returns "Access denied". ErrorString
is almost taken completely out of the PlatformSDK which is how Im
getting the error.
I've also tried opening the key with KEY_ALL_ACCESS and KEY_SET_VALUE
in combination with KEY_WRITE | KEY_READ as you see above.
Any ideas? The user is in the Administrator group. Thanks!