Results 1 to 7 of 7

Thread: [RESOLVED] X64 W7 Registry Delete Sub Keys

Threaded View

  1. #1

    Thread Starter
    Addicted Member xavierjohn22's Avatar
    Join Date
    Oct 2006
    Location
    Approx. 4921' and 3.11" asl
    Posts
    249

    Resolved [RESOLVED] X64 W7 Registry Delete Sub Keys

    Question:

    1)
    if i use the RegEnumKeyEx in X64 bit the hkey handle that is return is fine in the IDE, It deletes it

    If it is compiled already The Keyname lost 1 character at the end

    I have tried enumeration from the top too using regqueryinfo from highest number,
    it lost 1 character too when run after compiled so it does not delete the sub key

    in the IDE it deletes all sub keys?

    Any help from reg experts please?

    Note:
    the DeleteTree works fine in W7 x64, im doing delete sub keys that does not have subsubkeys
    If i use RegOpenKeyEx to return it it does not delete the subkey for both IDE and compiled

    Code:
    'testing building this for x64 key delete
    'Subkeys of a KEY, Subkey must not contain subkey
    Public Function Delete_KeySub(ByVal RootKey As HKEY_Type, ByVal sKey As String) As Boolean
        Dim lRegkey As Long, bFailed As Boolean
        Dim sName  As String, lNameLen As Long
        Dim sClass As String, lClassLen As Long
        Dim tFILETIME As FILETIME
        Dim lRetVal As Long
        Dim Index As Long
        On Error GoTo Handler
    
        lRetVal = RegOpenKeyEx(RootKey, sKey, 0, _
                KEY_WOW64_64KEY + KEY_ENUMERATE_SUB_KEYS, lRegkey)
                
        If Not lRetVal = ERROR_NONE Then GoTo Handler
        Index = 0
            
       Do
            sClass = Space$(255)
            sName = Space$(255)
            lClassLen = 255
            lNameLen = 255
            lRetVal = RegEnumKeyEx(lRegkey, Index, sName, lNameLen, ByVal 0, _
                sClass, lClassLen, tFILETIME)
            sName = Left(sName, lNameLen)
        
            MsgBox lRegkey & ":" & sName
    
            If lRetVal = ERROR_NONE Then
                Dim lsubkey As Long 'will not be use if i get lsubkey to return and delete
                    If RegOpenKeyEx(lRegkey, sName, 0, _
                        KEY_WOW64_64KEY + KEY_ALL_ACCESS, lsubkey) = ERROR_NONE Then
                        RegDeleteKeyEx lRegkey, sName, KEY_WOW64_64KEY + KEY_ALL_ACCESS, 0 ' just testing to delete no need for open by the way
                        'RegDeleteKeyEx lsubkey, sName, KEY_WOW64_64KEY + KEY_ALL_ACCESS, 0 'Why not working? 'lsubkey will not be use if this works
                    End If
                End If
                bFailed = True
            Else
                bFailed = False
            End If
        Index = Index + 1
        Loop Until Not lRetVal = 0
    
        ' Close the Key Handle
        Call RegCloseKey(lRegkey)
     
        Delete_KeySub = (Not bFailed)
        'MsgBox Delete_KeySub
    Handler:
        lRetVal = RegCloseKey(lRegkey)
        On Error GoTo 0
    End Function
    Last edited by xavierjohn22; Aug 7th, 2010 at 08:13 PM.

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