Thread: reg edit

  1. #1
    cpp.prog.newbie
    Guest

    reg edit

    is there a way to make a program that edits the registry on a computer provided that the value to edit is already there. Also have it that the value to change it to is already preset in the program so all you have to do is open it and it runs edits then closes itself with out needing to give the program any input at run time?

    srry if you have a hard time reading or understanding

  2. #2
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    Yes.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  3. #3
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    Posts
    856
    Originally posted by XSquared
    Yes.
    X^2, I agree with every point you made completely.

    So, newbie, you're saying you want to write a program that does nothing when it runs except edit an existing registry key and then exit.. Is that right? I have a program that does just that... Let me go find it...

    Ok, here's a snippet:
    Code:
    //---------------------cut here----------------------------
        // now make the change in the registry
        if (*valueName != 0 && *valueData != 0) {
          processedSomething = true;
    
          const char *keyPath = *key != 0 ? key : subKey;
    
          // if our key path has changed...
          if (keyChanged) {
            keyChanged = false;
    
            // close the previously opened key...
            if (hKey != NULL) {        
              RegCloseKey(hKey);
              hKey = NULL;
            }
    
            // then open our new path
            if (RegOpenKeyEx(baseKey, keyPath, 0, KEY_ALL_ACCESS, &hKey) != ERROR_SUCCESS) {
              logout << "* ERROR * - Unable to open registry key: \"" << baseKeyName << "\\" << keyPath << "\"" << endl;
              hKey = NULL;
            }
            else
              logout << "SUCCESS - Opened registry key: \"" << baseKeyName << "\\" << keyPath << "\"" << endl;
          }
    
          // if we have a key open
          if (hKey != NULL) {
            if (RegQueryValueEx(hKey, valueName, 0, NULL, NULL, NULL) != ERROR_SUCCESS)
              logout << "* ERROR * - Unable to query value: \"" << keyPath << "\\" << valueName << "\"" << endl;
            else {
              logout << "SUCCESS - Queried value: \"" << keyPath << "\\" << valueName << "\"" << endl;
                
              if (RegSetValueEx(hKey, valueName, 0, REG_SZ, valueData, strlen(valueData) + 1) != ERROR_SUCCESS)
                logout << "* ERROR * - Unable to set value: \"" << keyPath << "\\" << valueName << "\"=\"" << valueData << "\"" << endl;
              else
                logout << "SUCCESS - Set value: \"" << keyPath << "\\" << valueName << "\"=\"" << valueData << "\"" << endl;
            }        
          }
    
          // reset the value info
          *valueName = *valueData = 0;
        }
      }
    
      // close the handle to the registry key 
      if (hKey != NULL) {        
        RegCloseKey(hKey);
        hKey = NULL;
      }
    //---------------------cut here----------------------------

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    224
    thx for all your help

  5. #5
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    Posts
    856
    You're quite welcome.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. (Multiline) Edit Control Limit
    By P4R4N01D in forum Windows Programming
    Replies: 9
    Last Post: 05-17-2008, 11:56 AM
  2. line number on a rich edit control
    By rakan in forum Windows Programming
    Replies: 1
    Last Post: 02-18-2008, 07:58 AM
  3. Multiline Edit Box Parser
    By The Brain in forum Windows Programming
    Replies: 6
    Last Post: 11-01-2005, 07:15 PM
  4. Replies: 3
    Last Post: 07-23-2005, 08:00 AM
  5. reg edit
    By wiramu in forum Game Programming
    Replies: 1
    Last Post: 12-02-2003, 09:13 PM