Question and Answer Database FAQ2695C.txt How can I access/read something from the registry? Category :VCL Platform :Windows NT Product : C++Builder1.0 C++Builder3.x Question: How can I access/read something from the registry? Answer: // access registry and get location of Bordbk32.dll The code below is a very robust method to read something from the registry using VCL: String DebugPth; const String KeyStr = "\\software\\borland\\Borland Shared"; TRegistry *MyRegistry = new TRegistry(); MyRegistry->RootKey = HKEY_LOCAL_MACHINE; try { if (MyRegistry->OpenKey(KeyStr, false)) { DebugPth = MyRegistry->ReadString("SharedFilesDir") + "\\Debugger\\Bordbk32.dll"; if (DebugPth.IsEmpty()) { ShowMessage("Failed to read SharedFilesDir string value!"); MyRegistry->CloseKey(); delete MyRegistry; return 0; } } else { ShowMessage("Couldn't open key " + KeyStr); delete MyRegistry; return 0; } } catch(ERegistryException &E) { ShowMessage(E.Message); MyRegistry->CloseKey(); delete MyRegistry; return 0; } 6/8/98 11:33:38 AM
Last Modified: 01-SEP-99