SPONSORS:






User Tag List

Results 1 to 5 of 5
  1. #1
    Junior Member
    Join Date
    Dec 2000
    Location
    Hillsboro
    Posts
    16
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Deleting a registry key

    Is there a method for deleting registry keys?

  2. #2
    AJ
    AJ is offline
    Moderator AJ's Avatar
    Join Date
    Jun 1999
    Location
    San Jose, CA
    Posts
    1,691
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Deleting a registry key

    Yes,

    Download the registry functions in the QADownloads.com Segue section.


    ------------------
    AJ Alhait
    BetaSoft Inc.
    AJ Alhait
    BetaSoft Inc.

  3. #3
    Senior Member
    Join Date
    Oct 1999
    Location
    Tyngsborough, MA
    Posts
    211
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Deleting a registry key

    from MSDN...

    LONG RegDeleteKey(
    HKEY hKey, // handle to open key
    LPCTSTR lpSubKey // subkey name
    );

    first, you should be including msw32.inc.

    there are some constants declared in mswconst.inc for the registry hives...
    [ ] const HKEY_CURRENT_USER = 0x80000001
    [ ] const HKEY_LOCAL_MACHINE = 0x80000002
    [ ] const HKEY_USERS = 0x80000003
    [ ] const HKEY_PERFORMANCE_DATA = 0x80000004
    [ ] const HKEY_CURRENT_CONFIG = 0x80000005
    [ ] const HKEY_DYN_DATA = 0x80000006

    in mswtype.inc there are a bunch of msw types defined as Silk types. The two you need are missing however. You should add the folloing to a Silk include file of your own...
    [ ] type LPCTSTR is STRING
    [ ] type HKEY is INT


    if the key you want to delete is a subkey of one of these main keys, use the one of the constants as hKey and the name of the key as lpSubKey. If you need to delete a subkey of a subkey you will need to open it first. I'm not sure if this will work or not, I think it will.

    LONG RegOpenKeyEx(
    HKEY hKey, // handle to open key
    LPCTSTR lpSubKey, // subkey name
    DWORD ulOptions, // reserved //this should be 0 !!
    REGSAM samDesired, // security access mask
    PHKEY phkResult // handle to open key
    );

    add a couple more types to your include file

    [ ] type PHKEY is HANDLE
    [ ] type REGSAM is INT

    use one of the following constants as REGSAM, probably KEY_ALL_ACCESS. These constants are not declared anywhere, copy and paste from this message.

    [ ] //REGSAM
    [ ] const KEY_QUERY_VALUE = 0x0001
    [ ] const KEY_SET_VALUE = 0x0002
    [ ] const KEY_CREATE_SUB_KEY = 0x0004
    [ ] const KEY_ENUMERATE_SUB_KEYS = 0x0008
    [ ] const KEY_NOTIFY = 0x0010
    [ ] const KEY_CREATE_LINK = 0x0020
    [ ] const KEY_READ = STANDARD_RIGHTS_READ + KEY_QUERY_VALUE + KEY_ENUMERATE_SUB_KEYS + KEY_NOTIFY
    [ ] const KEY_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED + KEY_QUERY_VALUE + KEY_SET_VALUE + KEY_CREATE_SUB_KEY + KEY_ENUMERATE_SUB_KEYS + KEY_NOTIFY + KEY_CREATE_LINK
    [ ] const KEY_WRITE = STANDARD_RIGHTS_WRITE + KEY_SET_VALUE + KEY_CREATE_SUB_KEY


    Oh ya, you need to declare the dll that these functions live in.

    [ ]dll "Advapi32.dll"
    [ ] LONG RegOpenKeyEx(HKEY hKey, LPCTSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult);
    [ ] LONG RegDeleteKey(HKEY hKey, LPCTSTR lpSubKey);

    give this a shot, let me kow if it works. Did you ask for an easy way? I hope this isn't too hard.

  4. #4
    Senior Member
    Join Date
    Oct 1999
    Location
    Tyngsborough, MA
    Posts
    211
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Deleting a registry key

    AJ, I couldn't find your registry stuff. Where exactly is it located?

    Thanks

  5. #5
    Guest

    Re: Deleting a registry key

    Below is a code snippet that includes a couple of functions for deleting a registry key, or a specific value in a key.

    ------------------
    Tony Mrozinski
    Sr. Software Test Automation Engineer
    Home Networking Operations
    Intel Corporation

 

 

Posting Permissions

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

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 05:42 AM.

Copyright BetaSoft Inc.