Hi,
i want to check if a Registrykey exitst or not.
But I would not consider the key, but the folder in which it is located. In the folder, there is only the (standard) key.
Example:
To Check
HKLM "SOFTWARE\Test"
Not
HKLM "SOFTWARE\Test" "(Item)"
Can someone tell me how I can check?
Thank you
Check Registrykey Exists
9 posts
Sorry, but this document, I have already read, but it has not helped me. Can you give me perhaps explain how I use the key to verify existens.
I would be very grateful to you.
I would be very grateful to you.
A comment on terminology: the "folders" in the registry are called "keys". They can contain other keys (subfolders) and "values" (which have the properties "name", "type", and "data").
Registry keys always have at least one value, the "default" value. Your screen shot shows this as "standard". You can test for the existence of a key by reading the default value.
Registry keys always have at least one value, the "default" value. Your screen shot shows this as "standard". You can test for the existence of a key by reading the default value.
ClearErrors
ReadRegStr $0 HKLM "SOFTWARE\Test" ""
${If} ${Errors}
# key does not exist
${EndIf}
Thanks demiller9 for you help.
but it doesn't works correctly.
if i run your code, i will allways jump to
# key does not exist
Can you help me pls.
thanks
but it doesn't works correctly.
if i run your code, i will allways jump to
# key does not exist
Can you help me pls.
thanks
There isn't any simple function in NSIS to check is registry key exist, but you can use EnumRegKey as workaround.
This will work because EnumRegKey will only set the error flag if there is errors so even if the key doesn't have any sub keys to "enum", it doesn't set the error flag.ClearErrors
EnumRegKey $0 HKCR "SOFTWARE\Test" 0
IfErrors 0 keyexist
# key does not exist
keyexist:
GREAT!!!!!!!!!!!!!!
BIG THX!!!!!!
It works correctly!!! NICE!
Thanks
BIG THX!!!!!!
It works correctly!!! NICE!
Thanks
Originally posted by demiller9Yes they do have a default value name, but that value name has to have a value set for your code to work.
A comment on terminology: the "folders" in the registry are called "keys". They can contain other keys (subfolders) and "values" (which have the properties "name", "type", and "data").
Registry keys always have at least one value, the "default" value. Your screen shot shows this as "standard". You can test for the existence of a key by reading the default value.
ClearErrors
ReadRegStr $0 HKLM "SOFTWARE\Test" ""
${If} ${Errors}
# key does not exist
${EndIf}
Stu