Archive: Check for RegKey


Check for RegKey
Hi experts :)

I want to check a registry key during installation
unfortunatly there is a subkey (and I don´t know the
name of the subkey). So I can´t use "ReadRegStr" to check a
string of the name.
So is there a possibility to do a "CheckRegKey" (like
"DeleteRegKey") without knowing the subkeys ?

thank and br

rio


What do you mean by "checking"? Do you want to know the name of that subkey? Use EnumRegKey if that's the case. EnumRegKey will give you all of the subkeys of the desired regkey one by one.


@kichik: Thanks for your fast answer :)


With checking I mean: Exist this RegKey ?

EnumRegKey is fine if there are subkeys, but not on
all Win-Versions there are subkeys in the Key I want to
know if it exist. :cry:

Perhabs I have to do make a Win-version specific solution.

thanks
rio


EnumRegKey returns an empty string if there are no more keys, so you can just give it the first index (0 or 1) and if it returns an emtpy string, and the error flag is not set, the key is empty. If the error flag is set, there was an error.


Hi kichik,

Thanks.
One last question :D
If a key have one subkey, what is the index of this
subkey (0 or 1)?

best regards
rio


From MSDN:

dwIndex
[in] Index of the subkey to retrieve. This parameter should be zero for the first call to the RegEnumKeyEx function and then incremented for subsequent calls.
Because subkeys are not ordered, any new subkey will have an arbitrary index. This means that the function may return subkeys in any order.
So zero it is :D

Thank you :up:

rio