The best solution is to list auxiliary keys. Using RegEnumKeyEx , you just do it in a simple loop until there are no more keys to enumerate.
However, listing sub keys in Delphi using TRegistry even easier:
program _EnumSubKeys; {$APPTYPE CONSOLE} uses SysUtils, Classes, Windows, Registry; procedure EnumSubKeys(RootKey: HKEY; const Key: string); var Registry: TRegistry; SubKeyNames: TStringList; Name: string; begin Registry := TRegistry.Create; Try Registry.RootKey := RootKey; Registry.OpenKeyReadOnly(Key); SubKeyNames := TStringList.Create; Try Registry.GetKeyNames(SubKeyNames); for Name in SubKeyNames do Writeln(Name); Finally SubKeyNames.Free; End; Finally Registry.Free; End; end; begin EnumSubKeys(HKEY_LOCAL_MACHINE, 'Software\Microsoft'); Readln; end.
One thing that you should pay attention to is a search in the 64-bit representation of the registry. If you have a 64-bit version of MySQL installed, I expect it to use a 64-bit registry representation. In a 32-bit Delphi process on a 64-bit OS, you will need to redirect the registry to a side step. Do this by passing KEY_WOW64_64KEY to the TRegistry constructor.
The alternative you offer is hard coding of all possible version string values ββin your application. It sounds like a failure awaiting release as soon as a version is released that is not on your hard-coded list.
source share