armfly 发表于 2022-11-27 02:01:27

WIN11 注册表关于KEIL安装路径

Windows11系统:
      计算机\HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Keil\Products\MDK
                Path = C:\Keil_v5\ARM


CB10以后注册表的操作方式有所变化。
void __fastcall TForm2::InsertToRegBtnClick(TObject *Sender)
{
        TRegistry* reg = new TRegistry(KEY_READ);
        reg->RootKey = HKEY_LOCAL_MACHINE;

        if(!reg->KeyExists("Software\\MyCompanyName\\MyApplication\\"))
        {
                MessageDlg("Key not found! Created now.",
                                        mtInformation, TMsgDlgButtons() << mbOK, 0);
        }
        reg->Access = KEY_WRITE;
        bool openResult = reg->OpenKey("Software\\MyCompanyName\\MyApplication\\", true);

        if(!openResult)
        {
                MessageDlg("Unable to create key! Exiting.",
                                        mtError, TMsgDlgButtons() << mbOK, 0);
                return;
        }
        //Checking if the values exist and inserting when neccesary

        if(!reg->KeyExists("Creation\ Date"))
        {
                TDateTime today = TDateTime::CurrentDateTime();
                reg->WriteDateTime("Creation\ Date", today);
        }

        if(!reg->KeyExists("Licenced\ To"))
        {
                reg->WriteString("Licenced\ To", "MySurname\ MyFirstName");
        }

        if(!reg->KeyExists("App\ Location"))
        {
                reg->WriteExpandString("App\ Location",
                                                                "%PROGRAMFILES%\\MyCompanyName\\MyApplication\\");
        }

        if(!reg->KeyExists("Projects\ Location"))
        {
                reg->WriteExpandString("Projects\ Location",
                                                                "%USERPROFILE%\\MyApplication\\Projects\\");
        }

        reg->CloseKey();
        reg->Free();
}
//---------------------------------------------------------------------------
void __fastcall TForm2::DelFromRegBtnClick(TObject *Sender)
{
        //Deleting the example registry entries
        TRegistry* reg = new TRegistry(KEY_WRITE);
        reg->RootKey = HKEY_LOCAL_MACHINE;

        reg->DeleteKey("Software\\MyCompanyName\\MyApplication");
        reg->DeleteKey("Software\\MyCompanyName");

        reg->CloseKey();
        reg->Free();
}
//---------------------------------------------------------------------------

页: [1]
查看完整版本: WIN11 注册表关于KEIL安装路径