Purpose: Search for the MIMA item in the registry hkey_current_user / software / microsoft directory, create, then create, and read the content in MIMA, if the content is not 1, then rewriting the content of MIMA is 1, then refund Read the contents in MIMA and put the read content into the STR and display it in Edit1.
void __fastcall TForm1 :: Button1Click (TObject * Sender) {// join in the header file #include "Registry.hpp" String str; TRegistry * Registry = new TRegistry; // Create a Registry Registry-> RootKey = HKEY_CURRENT_USER; try {if (Registry-> OpenKey ("Software // Microsoft", True) == true) // Open key value Software // Microsoft, if this path is created, this path is created {if (! Registry-> Valueexists ("mima") ) // If the MIMA key value does not exist {registry-> CreateKey ("mima"); // Create a MIMA key value showMessage ("Create MIMA success!");} Str = registry-> readstring ("mima"); / / Read the content in MIMA and store it in the STR ((Str! = "1")) {registry-> WritestRing ("mima", "1"); // If the Str is not equal, write MIMA The value is 1} str = registry-> readstring ("mima"); // reads the value of MIMA again}} __finally {delete registry; // Delete Registry, release memory} Edit1-> text = STR;
}