Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12

Thread: Registry cleaner

  1. #11

    Default

    Reduced the code a little so I could test it in my environment:
    PHP Code:
    #define MAX_KEY_LENGTH 4096
    #define MAX_VALUE_NAME 4096
    #define MAX_KEY_LENGTH 4096


    void RegistryCleaner::querykey(HKEY hk, const char *kFILEfh)
    {
        
    char szBuffer[MAX_KEY_LENGTH];
        
    HKEY hKey;
        
    RegOpenKeyEx(hkk0KEY_ALL_ACCESS, &hKey);
        
    DWORD cSubKeys;
        
    DWORD maxSubkeyLen;
        
    DWORD retCode;

        
    RegQueryInfoKey(hKeyNULLNULLNULL, &cSubKeys, &maxSubkeyLenNULLNULLNULLNULLNULLNULL);

        if(
    cSubKeys 0)
        {
            static 
    char currentSubkey[MAX_PATH];

            
    int i;
            for(
    0cSubKeysi++)
            {
                
    DWORD currentSubLen=MAX_PATH;

                
    retCode RegEnumKeyEx(hKeyicurrentSubkey, &currentSubLenNULLNULLNULLNULL);

                if(
    retCode == ERROR_SUCCESS)
                {
                    
    char l[MAX_KEY_LENGTH];                                
                    
    sprintf(l"%s\\%s"kcurrentSubkey);

                    
    printf("%s\\%s\n"kcurrentSubkey); 
                    
    fputs(lfh);
                    
    fputs("\r\n"fh);

                    
    querykey(hklfh);
                }
            }
        }

        
    RegCloseKey(hKey);

    Called it with the following:
    PHP Code:
    RegistryCleanercleaner = new RegistryCleaner();
    FILEfh fopen("C:\\enum.txt""a+");
    cleaner->querykey(HKEY_CURRENT_USER"Software"fh); 
    And that worked fine as I'd get a nice list of all the subkeys of Software.

    Problem with your code is in the recursion.
    At some point your function will be called with "Software\2015" and it will print "Software\2015\MOHAA" to your Window as that's the only subkey. And because that's the deepest it can go, it will "go all the way back" to "Software". Then it will (for example) go into "7-Zip". Problem is that it will just print "Software\7-Zip" to your Window and overwrite any previously printed text as it has no knowledge of any previous calls.
    It would thus be better to append to your Window's Text instead of just Setting it.
    By that I mean this call:
    PHP Code:
    SetWindowText(hTestszBuffer); 
    Should be something like:
    PHP Code:
    char currentText[MAX_KEY_LENGTH]; 
    GetWindowText(hTestcurrentTextMAX_KEY_LENGTH);
    strcat(currentTextszBuffer);
    SetWindowText(hTestcurrentText); 
    MAX_KEY_LENGTH should probably be something else though.
    =|UWS|=|SA|Vince - Head Serveradmin - mohaa.uwsclan.us (MOH:AA - FT)

  2. #12
    Administrator James's Avatar
    Join Date
    May 2010
    Location
    on the intraweb
    Posts
    3,180

    Default

    Dude thank you SOOOO much! Wow, I feel like an idiot. That was such a huge help!

Posting Permissions

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