Link to home
Start Free TrialLog in
Avatar of jimrichmond
jimrichmond

asked on

Problems Creating a Key under HKEY_LOCAL_MACHINE in Vista

We have written a C++ application that creates a registry key to store information in.  On XP computers it works fine and on most Vista computers (Home Premium) it works fine.  However on some Vista Computers it will not create the key.  Otherwise the program works fine, but the key is never created.
The key we're creating is in HKEY_LOCAL_MACHINE\SOFTWARE.  The command we're using to create it is
LONG lRes = RegCreateKeyEx(HKEY_LOCAL_MACHINE, "Software\\OurKey\0", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &RegKey, NULL);

The user is logged in as an administrator. Does anybody have any Ideas why, in only a few cases, the key is not created?
SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi jkr,

One would think that Microsoft would embrace Registry Virtualization as a way to help slow the proliferation of worms and other viruses instead of declaring it obsolete the instant it's announced.


Kent
Security in Vista has changed, even though the user might belong to the Administrators group the process will not run with administrator privileges unless the user explicitly permitted it. You will have to create security descriptor through an instance of SECURITY_ATTRIBUTES structure and pass a pointer to the structure to the RegCreateKeyEx function (currently you are passing NULL for this optional parameter) and ask the OS to elevate the privileges.

The following 2 articles might be useful:

http://msdn.microsoft.com/en-us/library/aa379560(VS.85).aspx
http://msdn.microsoft.com/en-us/library/aa446595(VS.85).aspx
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial