Thread: Working with the Registry Win 2000

  1. #1
    ReggerX
    Guest

    Working with the Registry Win 2000

    Does anybody have any good reference programs that he/she could share that deal with Working with the Registry under Win 2000 Pro ?

    I need to search for a key (a string of about 27 digits) and delete all occurances

    Comments/Suggestions/Advice Welcome

  2. #2
    icarus
    Guest
    You could always try that great institution of learning and instruction known to the wise as MSDN, but perhaps the secrets it contains are too great for you! Your mind could explode!

  3. #3
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    here's a link to the actual section you'll need

    http://msdn.microsoft.com/library/de...asp?frame=true

    responding to a post where someone is looking for help with "search on google" or "search msdn" is really annoying. a lot of people around here don't understand that the board can be used for research and people aren't being lazy by coming here looking for an answer.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Originally posted by FillYourBrain
    responding to a post where someone is looking for help with "search on google" or "search msdn" is really annoying. a lot of people around here don't understand that the board can be used for research and people aren't being lazy by coming here looking for an answer.
    Yes but after the first time a question has been properly answered, then it can be searched for and re-read....

    And once a question has been answered more than say 50 times there's not really a need to ask again

  5. #5
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    EVERY question has already been asked. Nothing you have ever said is truly original. <--already been said.

    the point is a message board's general purpose is conversation. Pick out just about any thread and it can be shown to have been talked about before. there is way too much high and mighty "don't bother me, use a search enginge" attitude as if you're conversation is more relevant than someone else's
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  6. #6
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Originally posted by FillYourBrain
    EVERY question has already been asked. Nothing you have ever said is truly original. <--already been said.

    the point is a message board's general purpose is conversation. Pick out just about any thread and it can be shown to have been talked about before. there is way too much high and mighty "don't bother me, use a search enginge" attitude as if you're conversation is more relevant than someone else's
    I disagree.....there are problems & requests for guidance (which are always worthwhile) and then there are questions which come up week by week without fail and are only asked because the person asking hasnt bothered to look for the answer with a search.....I agree that icarus response might be a bit OTT, but it can be frustrating seing the same basic questions one after another.... ....

    You can agree or disagree....but when you have answered the same group of questions over and over again, you might feel differently..

  7. #7
    ReggerX
    Guest
    Thanks for the posts, and NOT saying go to google.com

    I DO know of google and all it's powers but I was looking to the board for HIGHER learning and people with experience.

    I went to google and downloaded someone's registry class wrapper, it looks good but there is no documentation as to how to use it ! [sarcasm] Great ! [/sarcasm]

  8. #8
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    here

    Have some time reading those....if you have any specific problems please post some code

  9. #9
    ReggerX
    Guest
    All those API functions are fine but, what I'm looking to do is :

    Search for a key (a string of about 27 digits) and delete all occurances of it, through the Local_Machine

    None of the wrappers of functions seem to be able to search through the Reg, it's works only when you know the exact path


    Thoughts ?

  10. #10
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    Seems simple enough. Two minutes research found

    RegEnumKeyEx()

    Put it in a loop and watch the returns.

    Or is there something I am missing?
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  11. #11
    ReggerX
    Guest
    I have this code from MSDN and it includes novacain's mentioned function.

    To Search for a Value and a Key and delete all occurances of it, through the Local_Machine...What part is relevant ?

    I guess you can tell I don't have much API experience

    Any help appreciated

    Code:
    // QueryKey - Enumerates the subkeys of key, and the associated 
    //    values, then copies the information about the keys and values 
    //    into a pair of edit controls and list boxes. 
    // hDlg - Dialog box that contains the edit controls and list boxes.
    // hKey - Key whose subkeys and values are to be enumerated.
     
    void QueryKey(HWND hDlg, HANDLE hKey) 
    { 
        CHAR     achKey[MAX_PATH]; 
        CHAR     achClass[MAX_PATH] = "";  // buffer for class name 
        DWORD    cchClassName = MAX_PATH;  // size of class string 
        DWORD    cSubKeys;                 // number of subkeys 
        DWORD    cbMaxSubKey;              // longest subkey size 
        DWORD    cchMaxClass;              // longest class string 
        DWORD    cValues;              // number of values for key 
        DWORD    cchMaxValue;          // longest value name 
        DWORD    cbMaxValueData;       // longest value data 
        DWORD    cbSecurityDescriptor; // size of security descriptor 
        FILETIME ftLastWriteTime;      // last write time 
     
        DWORD i, j; 
        DWORD retCode, retValue; 
     
        CHAR  achValue[MAX_VALUE_NAME]; 
        DWORD cchValue = MAX_VALUE_NAME; 
        CHAR  achBuff[80]; 
     
        // Get the class name and the value count. 
        RegQueryInfoKey(hKey,        // key handle 
            achClass,                // buffer for class name 
            &cchClassName,           // size of class string 
            NULL,                    // reserved 
            &cSubKeys,               // number of subkeys 
            &cbMaxSubKey,            // longest subkey size 
            &cchMaxClass,            // longest class string 
            &cValues,                // number of values for this key 
            &cchMaxValue,            // longest value name 
            &cbMaxValueData,         // longest value data 
            &cbSecurityDescriptor,   // security descriptor 
            &ftLastWriteTime);       // last write time 
     
        SetDlgItemText(hDlg, IDE_CLASS, achClass); 
        SetDlgItemInt(hDlg, IDE_CVALUES, cValues, FALSE); 
     
        SendMessage(GetDlgItem(hDlg, IDL_LISTBOX), 
            LB_ADDSTRING, 0, (LONG) ".."); 
     
        // Enumerate the child keys, until RegEnumKeyEx fails. Then 
        // get the name of each child key and copy it into the list box. 
    
        SetCursor(LoadCursor(NULL, IDC_WAIT)); 
        for (i = 0, retCode = ERROR_SUCCESS; 
                retCode == ERROR_SUCCESS; i++) 
        { 
            retCode = RegEnumKeyEx(hKey, 
                         i, 
                         achKey, 
                         MAX_PATH, 
                         NULL, 
                         NULL, 
                         NULL, 
                         &ftLastWriteTime); 
            if (retCode == (DWORD)ERROR_SUCCESS) 
            {
                SendMessage(GetDlgItem(hDlg, IDL_LISTBOX), 
                    LB_ADDSTRING, 0, (LONG) achKey); 
            }
        } 
        SetCursor(LoadCursor (NULL, IDC_ARROW)); 
     
        // Enumerate the key values. 
        SetCursor(LoadCursor(NULL, IDC_WAIT)); 
     
        if (cValues) 
        {
            for (j = 0, retValue = ERROR_SUCCESS; 
                    j < cValues; j++) 
            { 
                cchValue = MAX_VALUE_NAME; 
                achValue[0] = '\0'; 
                retValue = RegEnumValue(hKey, j, achValue, 
                    &cchValue, 
                    NULL, 
                    NULL,    // &dwType, 
                    NULL,    // &bData, 
                    NULL);   // &bcData 
     
                if (retValue == (DWORD) ERROR_SUCCESS ) 
                { 
                    achBuff[0] = '\0'; 
     
                    // Add each value to a list box. 
                    if (!lstrlen(achValue)) 
                        lstrcpy(achValue, "<NO NAME>"); 
                    wsprintf(achBuff, "%d) %s ", j, achValue); 
                    SendMessage(GetDlgItem(hDlg,IDL_LISTBOX2), 
                        LB_ADDSTRING, 0, (LONG) achBuff); 
                } 
            }
    
        SetCursor(LoadCursor(NULL, IDC_ARROW)); 
    }

  12. #12
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    If you can't work out how to search the registry from that code, to delete what I presume is a serial number or demo expiry date, then I don't think you should be playing with such an important Windows component.

    If you get a version half way there and still have problems post again.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  13. #13
    ReggerX
    Guest
    What I'm trying to delete is a product that i can't uninstall the traditional way and has manifested itself in 120 locations in the registry and i don't feel up to deleting 120 times per machine times 30 machines in the office.

    bad situation i know !

    parsing the registry, even worse, nobody knows how

  14. #14
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Originally posted by ReggerX
    What I'm trying to delete is a product that i can't uninstall the traditional way and has manifested itself in 120 locations in the registry and i don't feel up to deleting 120 times per machine times 30 machines in the office.
    What kind of program would do that?? Some kind of virus?

    Originally posted by ReggerX
    parsing the registry, even worse, nobody knows how
    The links you have been given should provide waht you need.....

  15. #15
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    you know fordy, that hadn't even occurred to me. We're probably helping this guy write a virus here. Registry access/delete should only really be done to a key that you are aware of. Outside of a "registry cleanup" utility you really shouldn't be messing with other program's entries. Even then you have to be really careful.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 05-07-2009, 11:31 AM
  2. Registry, Regedit
    By franse in forum C++ Programming
    Replies: 21
    Last Post: 01-29-2009, 09:57 AM
  3. Can I get this to loop back?
    By Unregistered in forum C Programming
    Replies: 9
    Last Post: 05-07-2002, 03:34 AM
  4. Win XP or 2000?
    By andy668 in forum Windows Programming
    Replies: 8
    Last Post: 01-15-2002, 10:15 PM
  5. Debugger in Visual C++ UNDER Win 2000
    By porecha_jp in forum Windows Programming
    Replies: 0
    Last Post: 11-22-2001, 09:19 PM