cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
aushami
Level 3

facing issue RegDBSetKeyValueEx Creating new key even though the key exists?

Hey guys,
I am new to installshield scripting. I have basic MSI project, where I needed to write custom InstallScript function to update the value of existing key. Now by definition RegDBSetKeyValueEx creates the key if it doesnt find it but in my case the key already exists, so it shouldn't be creating a new key. I have verified it with RegDBKeyExist function. Any idea why it is doing that?

RegDBSetDefaultRoot ( HKEY_CLASSES_ROOT );

if (RegDBKeyExist(szKey) < 0) then
MessageBox ("Key Exists.", INFORMATION);
endif;

if (RegDBSetKeyValueEx (szKey, "", nType, szNumValue,
nSize) < 0) then
MessageBox ("RegDBSetKeyValueEx failed.", SEVERE);
abort;
else
MessageBox ("RegDBSetKeyValueEx passed.", INFORMATION);
endif;
Labels (1)
0 Kudos
(4) Replies
aushami
Level 3

Bumping this thread!
0 Kudos
Not applicable

You are creating a new 'default' key by passing "" as a parameter, but you are only checking for the key root. Would that perhaps be the reason?
0 Kudos
aushami
Level 3

Hysteresis wrote:
You are creating a new 'default' key by passing "" as a parameter, but you are only checking for the key root. Would that perhaps be the reason?


Thank you for responding. I am passing "" to set the value of the key for (Default).
0 Kudos
aushami
Level 3

Finally fixed it. It was mistake. There was a space at the end of key name, InstallScript doesnt trim tailoring space. Which was causing in creation of new key in the registry.
Thanks!
0 Kudos