Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Delete from Registry using VBA
Hi Guys,
I really need help with this one! I need to be able to delete some entries in the Registry from VBA, and deleting values and keys with no sub-keys works fine, but problems occurs when a key have subkeys. I'm using 'WShell.RegDelete RegistryKey' to delete the entries, no matter if it is a value or a key, but, as you all probably know, you cannot delete a key, if it has subkeys. So, I'm trying to use 'RegObject.ENumKey HKEY, DeleteKey, SubKeys' to get the number of subkeys to be able to delete those first... ....and it works... ....provided that those subkeys doesn't have any subkeys themselves! So, to solve this problem, I'm trying to create an UDF to do the work instead, so I can just call this UDF, like: DelRegKeyVal(Key) ('Key' can also be a value) ....which should then delete the 'Key' no matter if it is a value or key. But, since I don't know how many levels down, the key has subkey (if the name of the argument is an actually key), how do I make sure all sub-, sub-, sub- keys are deleted before getting up to the level of 'Key'? Does all this make sense? Does anyone undderstand my problem, and can help? Thanks, CE |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Delete from Registry using VBA
Charlotte E. wrote:
Hi Guys, I really need help with this one! I need to be able to delete some entries in the Registry from VBA, and deleting values and keys with no sub-keys works fine, but problems occurs when a key have subkeys. I'm using 'WShell.RegDelete RegistryKey' to delete the entries, no matter if it is a value or a key, but, as you all probably know, you cannot delete a key, if it has subkeys. So, I'm trying to use 'RegObject.ENumKey HKEY, DeleteKey, SubKeys' to get the number of subkeys to be able to delete those first... ...and it works... ...provided that those subkeys doesn't have any subkeys themselves! So, to solve this problem, I'm trying to create an UDF to do the work instead, so I can just call this UDF, like: DelRegKeyVal(Key) ('Key' can also be a value) ...which should then delete the 'Key' no matter if it is a value or key. But, since I don't know how many levels down, the key has subkey (if the name of the argument is an actually key), how do I make sure all sub-, sub-, sub- keys are deleted before getting up to the level of 'Key'? Does all this make sense? Does anyone undderstand my problem, and can help? Thanks, CE have you hard word recursion ? n! = n*(n-1)! exit if not subkey exits delete key. call itself with each subkey as parameter. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Delete from Registry using VBA
?????
CE "witek" wrote in message ... Charlotte E. wrote: Hi Guys, I really need help with this one! I need to be able to delete some entries in the Registry from VBA, and deleting values and keys with no sub-keys works fine, but problems occurs when a key have subkeys. I'm using 'WShell.RegDelete RegistryKey' to delete the entries, no matter if it is a value or a key, but, as you all probably know, you cannot delete a key, if it has subkeys. So, I'm trying to use 'RegObject.ENumKey HKEY, DeleteKey, SubKeys' to get the number of subkeys to be able to delete those first... ...and it works... ...provided that those subkeys doesn't have any subkeys themselves! So, to solve this problem, I'm trying to create an UDF to do the work instead, so I can just call this UDF, like: DelRegKeyVal(Key) ('Key' can also be a value) ...which should then delete the 'Key' no matter if it is a value or key. But, since I don't know how many levels down, the key has subkey (if the name of the argument is an actually key), how do I make sure all sub-, sub-, sub- keys are deleted before getting up to the level of 'Key'? Does all this make sense? Does anyone undderstand my problem, and can help? Thanks, CE have you hard word recursion ? n! = n*(n-1)! exit if not subkey exits delete key. call itself with each subkey as parameter. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Delete from Registry using VBA
Never mind, guys - found a solution :-)
CE "Charlotte E." wrote in message ... Hi Guys, I really need help with this one! I need to be able to delete some entries in the Registry from VBA, and deleting values and keys with no sub-keys works fine, but problems occurs when a key have subkeys. I'm using 'WShell.RegDelete RegistryKey' to delete the entries, no matter if it is a value or a key, but, as you all probably know, you cannot delete a key, if it has subkeys. So, I'm trying to use 'RegObject.ENumKey HKEY, DeleteKey, SubKeys' to get the number of subkeys to be able to delete those first... ...and it works... ...provided that those subkeys doesn't have any subkeys themselves! So, to solve this problem, I'm trying to create an UDF to do the work instead, so I can just call this UDF, like: DelRegKeyVal(Key) ('Key' can also be a value) ...which should then delete the 'Key' no matter if it is a value or key. But, since I don't know how many levels down, the key has subkey (if the name of the argument is an actually key), how do I make sure all sub-, sub-, sub- keys are deleted before getting up to the level of 'Key'? Does all this make sense? Does anyone undderstand my problem, and can help? Thanks, CE |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro to Write and delete value in registry | Excel Programming | |||
Automation & Registry | Excel Programming | |||
Value from Registry | Excel Programming | |||
Registry | Excel Programming | |||
Registry | Excel Programming |