I do not understand. There is a window registry key of firebird server I want to check if it exists. The key exists but the function returns false. What is wrong? I'm using Windows 7 64x with delphi 2010.
Tks. Davis.
procedure x;
var
reg:TRegistry;
begin
reg := TRegistry.Create;
reg.RootKey := HKEY_LOCAL_MACHINE;
if reg.OpenKey('\SOFTWARE\Firebird Project\Firebird Server\Instances',false)=true then
begin
ShowMessage('Key exists');
end;
end;
I think since you look at the registry from a 32 bit process on a 64 bit operating system, you are indeed looking at the "virtual" registry tree. In fact, an hidden "sub-redirection" is at work here.
See the registry changes in x64-based versions of Windows Server 2003 and in Windows XP Professional x64 Edition at Microsoft.
(quoted from the Microsoft page above)
So if your firebird process installed the keys in 64 bit mode, they won't be visible from a 32 bit process. And you'll need a 32 bit FireBird client to let it work with Delphi (unless you are using Delphi XE2 64 Bit mode).
Try to run your application as administrator. I think this will solve your problem.
The most likely reason is that you have opened the key requesting write access but on Windows 7 under UAC, users do not, by default, have write access to
HKLM
. Solve this by passingKEY_READ
to theTRegistry
constructor, or by usingOpenKeyReadOnly
rather thanOpenKey
.The next most likely explanation is that you have the 64 bit Firebird server installed. But your 32 bit program reads from the 32 bit registry and so does not find the keys from the 64 bit Firebird. See Registry Redirector to learn more about the two different registry views. See Accessing an Alternate Registry View for details on how to read the 64 bit registry from a 32 bit process. Translated into Delphi, you would need to include
KEY_WOW64_64KEY
in theAccess
flags. Again, you can pass this flag to theTRegistry
constructor which may be more convenient.So, in summary, if you are looking for a 32 bit server, create the registry object like this
and if your Firebird server is 64 bit then use this
Try replacing
with