Polaris
2009-11-22 07:58:10 UTC
Hi Experts:
I'm writing a console app which accesses and changes some values under
Windows registry: HKLM\System\CurrentControlSet\Enum and I'm the admin on
the machine (XP).
I have done the following steps but failed at step #4 with access denied
error.
1. Get the process handle with PROCESS_ALL_ACCESS; success.
2. Get the token handle with TOKEN_ALL_ACCESS; success.
3. Adjust token privilege to SE_TAKE_OWNERSHIP_NAME; success.
4. open the reg key "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Enum" using
RegOpenKeyEx with KEY_ALL_ACCESS (tried also WRITE_ONWER); but failed with
return code 5 (Access Denied).
If I manually change the permission for "EVERYONE" with full permissions
using RegEdit.exe, it worked fine. But this is not what I want. I like the
app to be able to programmatically do that through certain steps (hopefully
similar steps to what I have tried above).
Any pointer on the possible cause is appreciated.
Thanks in Advance.
Polaris
I'm writing a console app which accesses and changes some values under
Windows registry: HKLM\System\CurrentControlSet\Enum and I'm the admin on
the machine (XP).
I have done the following steps but failed at step #4 with access denied
error.
1. Get the process handle with PROCESS_ALL_ACCESS; success.
2. Get the token handle with TOKEN_ALL_ACCESS; success.
3. Adjust token privilege to SE_TAKE_OWNERSHIP_NAME; success.
4. open the reg key "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Enum" using
RegOpenKeyEx with KEY_ALL_ACCESS (tried also WRITE_ONWER); but failed with
return code 5 (Access Denied).
If I manually change the permission for "EVERYONE" with full permissions
using RegEdit.exe, it worked fine. But this is not what I want. I like the
app to be able to programmatically do that through certain steps (hopefully
similar steps to what I have tried above).
Any pointer on the possible cause is appreciated.
Thanks in Advance.
Polaris