Reputation:
I want to write a registry value into
HKEY_CURRENT_USER\Software\Adobe\Acrobat Reader\11.0\Identity => key = tName , value="user1"
but every time I got "RegOpenKeyEx SOFTWARE\Adobe\Acrobat Reader\11.0\Identity failed (error=2) "
as error suggest the Identity key is not present in the registry.
How to create a registry if it is not present. I want to create if the key is not present and open it registry is there.
lStat = RegOpenKeyEx( HKEY_CURRENT_USER, /*handle of open key */
szSubKey, /* address of name of subkey to open */
0, /* reserved */
KEY_READ , /* security access mask */
&hKey /* address of handle of open key */
);
if ( lStat != ERROR_SUCCESS) {
sprintf(szMsg,"RegOpenKeyEx %s failed (error=%ld) ",
szSubKey, lStat);
traceMsg(szMsg);
return lStat;
}
lStat = RegSetValueEx(hKey,(LPCTSTR)szValue, NULL, &Type,
(LPBYTE)szUser, strlen(szUser)+1);
Upvotes: 0
Views: 566
Reputation: 10557
Does this key exist there? MSDN:
Unlike the RegCreateKeyEx function, the RegOpenKeyEx function does not create the specified key if the key does not exist in the registry.
Try regedit
first.
Second, you specify KEY_READ
and then want to write something.
Upvotes: 1