Results 1 to 3 of 3

Thread: How to delete a subkey from windows registry?

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2007
    Posts
    1

    Smile How to delete a subkey from windows registry?

    Hi!! all,

    I am developing a multimedia player. I wanted to add an context menu option, it will be displayed when user right-clicks on any multimedia file and when someone clicks that option it will load my player along with the selected file playing on it. I've done this. I've created this in win registry and its looks like this :-

    HKEY_CLASSES_ROOT\*\shell\Play in Ex-MediaPlayer\command

    after command, the default value contains the fullpath to my player's exe file. Now I want to remove the entire key chain from shell to command and the default value from registry. Can it be possible? If yes, then please help me. Its very urgent for me as I'm developing an uninstaller for my apps.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: How to delete a subkey from windows registry?

    Moved from the CodeBank

  3. #3
    Fanatic Member schoolbusdriver's Avatar
    Join Date
    Jan 2006
    Location
    O'er yonder
    Posts
    1,020

    Re: How to delete a subkey from windows registry?

    The safe way is to use RegDeleteKey on each of the subkeys in the branch, enumerating and checking each subkey for values (using RegEnumValue), just in case another app has used the same registry path as your own. That way you don't erase another progs settings. i.e. Although RegDeleteKey will delete a subkey which contains values, it won't delete a subkey which contains other subkeys (possibly written by another app) - hence the need to enumerate and check any values that may belong to another prog.

    An API which will delete a subkey, and any other subkeys and values it contains, is SHDeleteKey. I must point out though, that if you erroneously pass the wrong branch/subkey to SHDeleteKey, it will wipe it out without question - possibly leaving you with the problem of re-installing an OS. You should create a .reg file backup - or restore point, just in case.
    Last edited by schoolbusdriver; Mar 18th, 2007 at 06:22 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width