Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 160
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 147
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 160
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 160
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to Write and delete value in registry Jitendra Kumar[_2_] Excel Programming 1 June 2nd 08 07:19 PM
Automation & Registry AA2e72E Excel Programming 3 March 10th 06 10:23 PM
Value from Registry Roy Lasris Excel Programming 3 February 23rd 04 11:53 PM
Registry Tom Ogilvy Excel Programming 1 July 16th 03 01:02 AM
Registry Patrick Molloy[_4_] Excel Programming 0 July 15th 03 12:45 PM


All times are GMT +1. The time now is 11:47 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"