TRegistry::KeyExists() fails when key is a componentID like {ABC-...} [Rad Studio]

16 Views Asked by At

In RAD Studio 2009, KeyExists() works without the ID {1D30003C-A1G4-22E5-CGSH-833A4E1X1234}. I copied the ID from the Registry Editor. Does the ID need to be formatted differently somehow?

Path copied directly from Registry Editor:

Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{1D30003C-A1G4-22E5-CGSH-833A4E1X1234}

TRegistry* reg = new TRegistry(KEY_READ);
reg->RootKey = HKEY_LOCAL_MACHINE;
if (reg->KeyExists(L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{1D30003C-A1G4-22E5-CGSH-833A4E1X1234}"))
{
   ShowMessage("successful");
}
reg->CloseKey();
reg->Free();

Can anyone here help me out?

1

There are 1 best solutions below

2
On

Found it. I need "KEY_READ | KEY_WOW64_64KEY" to get access for IDs. I don't understand why, but now its working.

https://learn.microsoft.com/en-us/windows/win32/winprog64/accessing-an-alternate-registry-view

In Rad Studio KEY_WOW64_64KEY was not mentioned https://docwiki.embarcadero.com/Libraries/Sydney/en/System.Win.Registry.TRegistry.Access