472,977 Members | 1,746 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,977 software developers and data experts.

RegSetValueEx

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!

Jul 11 '06 #1
2 2182
if ( RegSetValueEx(hkeyFirewall, "EnableFirewall", 0, REG_DWORD,
(BYTE*)0, sizeof(DWORD)) != ERROR_SUCCESS )
(BYTE*)0

is wrong. you are supposed to supply a pointer to a variable that contains
the data.
you supply a pointer with value 0, i.e. you supply a NULL pointer.

do something like this

DWORD val = 0;
if ( RegSetValueEx(hkeyFirewall, "EnableFirewall", 0, REG_DWORD,
(BYTE*)&val, sizeof(DWORD)) != ERROR_SUCCESS )

Though why this triggers an access denied error i don't know.
my first guess was that your program is not running with admin credentials,
but apparently you already thought of that.

--

Kind regards,
Bruno van Dooren
br**********************@hotmail.com
Remove only "_nos_pam"
Jul 11 '06 #2

Bruno van Dooren wrote:
if ( RegSetValueEx(hkeyFirewall, "EnableFirewall", 0, REG_DWORD,
(BYTE*)0, sizeof(DWORD)) != ERROR_SUCCESS )

(BYTE*)0

is wrong. you are supposed to supply a pointer to a variable that contains
the data.
you supply a pointer with value 0, i.e. you supply a NULL pointer.

do something like this

DWORD val = 0;
if ( RegSetValueEx(hkeyFirewall, "EnableFirewall", 0, REG_DWORD,
(BYTE*)&val, sizeof(DWORD)) != ERROR_SUCCESS )

Though why this triggers an access denied error i don't know.
my first guess was that your program is not running with admin credentials,
but apparently you already thought of that.

--

Kind regards,
Bruno van Dooren
br**********************@hotmail.com
Remove only "_nos_pam"
I tried it like that and to no avail... same results. Here is the
updated copy:

DWORD value = 0;
if ( RegSetValueEx(hkeyFirewall, "EnableFirewall", 0, REG_DWORD,
(LPBYTE) &value, sizeof(DWORD)) != ERROR_SUCCESS )

Any other ideas? Am I the only one with this issue?

Jul 12 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Lauren Quantrell | last post by:
Maybe a dumb question - I'm new to ODBC. How do I install an Access ..mde file on a user's workstation and create the ODBC connection to the backend SQL Server database without having to go through...
1
by: Dan | last post by:
Hi I have recently converted an Access 97 database to 2003. Most of the change went fine with no problems but every now and then my DSN connections to my back-end SQL-database fail and it does not...
1
by: Dan | last post by:
Hi I have recently converted an Access 97 database to 2003. Most of the change went fine with no problems but every now and then my DSN connections to my back-end SQL-database fail and it does not...
5
by: Alec | last post by:
Hi All, I am currently trying to link in Access 97 to a table in a MSSQL 7 server. Initially the link is fine, however, when I close the access database and re-open it from the same network...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.