View Full Version : DeleteRegKey?
24th May 2001, 09:05
Is there a way to remove a certain registry key on the condition that it's completely empty?
Say I have this layout:
which is createed on install.
On uninstall, I will DeleteRegKey that key, but I can't delete Alex just in case other programs by this particular author are installed.
And I'd prefer not to leave it there. I personally hate empty keys under Software.
Koen van de Sande
24th May 2001, 16:00
Don't think so, because DeleteRegKey is recursive nowadays... Don't really like that, there should be an option /r or something which controls this.
24th May 2001, 16:52
I actually suggest such modifications for a few times but never got a response. What is really needed are methods to 1. check if a key contains
a) any values
b) any subkeys
2. retrieve the names of
a) the values
b) the subkeys
24th May 2001, 18:51
why don't you just read the keys (ReadRegKey), compare them (StrCmp)and if they aren't empty remove them (DeleteRegKey).
what has that to do with recursive?
if you don't want do delete a special key you don't have to, do you?
25th May 2001, 07:58
Thanks, yzo, but is there a way to just check if any stuff exists under the key? I couldn't see if something specific is there, because if that specific something isn't there and other stuff is, boom.
25th May 2001, 13:02
when i remove a key i know what i delete, because i wrote it there, so i know which value i have to read and compare before deleting.
if you aren't sure, why would you want to delete a regkey
which you don't know if it is empty or usefull with your installer?
why don't you use DeleteRegValue instead?
25th May 2001, 13:10
Okay, well, I install to
and on uninstall, I delete
I would like to be able to also delete
but I can't just in case this user has installed another program:
And I don't particularly wish to leave an empty Alex key behind. I'd prefer a completely clean install.
Snowbird, I agree with you on 1. a) b). But I believe 2. a) b) can be done now.
25th May 2001, 13:18
if you write a key to HKCU\Software\Alex\ProgramA
you should know other possible keys under HKCU\Software\Alex\ ( 'cause it seems like you were Alex ;) )
so you could check for them, couldn't you?
Koen van de Sande
25th May 2001, 13:29
But you don't know right now which programs you are going to write in the future, so you don't know the names of ProgramC and ProgramD :)
Just my idea.
25th May 2001, 13:41
LOL .. sure.
yeah koen you are right, i didn't think of that .. uhh ..
so ReadRegValues would be quite useful!
26th May 2001, 07:38
How do you think it is possible now to discover the names of the values? I don't think this is possible. Maybe I have to be more precise: I want to obtain a list containing all the names of the values/subkeys.
A problem I see here with respect to the implementation is that NSIS doesn't know any list data type. However, the following should be possible to implement:
1. FirstRegValueName HKEY SUBKEY $x
Will retrieve the name of the first value in SUBKEY and write it to $x or throw an error if there is none.
2. NextRegValueName HKEY SUBKEY $x
Will retrieve the next name and write it to $x or throw an error if there is none.
I implemented some C functions to do this, however I never had a look at the NSIS source code, so I don't feel fit to hack this into NSIS. Anyone feeling fit to do so who wants the code, please let me know.
vBulletin® v3.8.6, Copyright ©2000-2013, Jelsoft Enterprises Ltd.