2

Problem: I need to modify aliases.conf in firebird but.. as we know the user can install firebird anywhere he want. So I need to programmatically find out where the firebird was installed. I try to do that by registry but it's not good idea because withe almost every one new version of windows (2000, XP, VISTA, 7, 8 and 32 bit or 64 bit and may be 128 bit) the registry keys get change. I try also find out procedure for searching registry like simple text file but no result. I have try to find the "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\SharedDLLs\aliases.conf" but it's not simple way. It's possible that the problem is not in registry function just in Lazarus but I do not know that. So, may be some one has any idea how to check if and where is installed firebird. Shortly say: I'm going to install my application with database file and have to have silently modify the aliases.conf.

2
  • 1
    Give up on it, ask the user. Firebird might not have been locally installed. Worse, there might be a local, inactive installation, and a remote running server. That would be the case if I installed your program... Commented Jul 11, 2014 at 14:32
  • "aliases.conf" is not a DLL, so there's no reason to expect it to be in the SharedDLL registry entry. You shouldn't be "silently modifying" anything that concerns the user's database configuration, as you could break another (possibly critical) application that isn't yours. Commented Jul 11, 2014 at 17:31

1 Answer 1

5

You can find the installation location of Firebird by checking the registry key HKLM\Software\Firebird Project\Firebird Server\Instances and reading the DefaultInstance value.

The following code should do the trick :-

var
  lReg : TRegistry;
  lStr : String;
begin
  lReg := TRegistry.Create;
  Try
    lReg.RootKey := HKEY_LOCAL_MACHINE;
    If lReg.OpenKey('Software\Firebird Project\Firebird Server\Instances', False) Then
      lStr := lReg.ReadString('DefaultInstance');
    lReg.CloseKey;
    ShowMessage(lStr);
  Finally
    FreeAndNil(lReg);
  End;
Sign up to request clarification or add additional context in comments.

9 Comments

Andy_D I have use this function but is not work. function TfrMain.GetSubKeys(ARegStr: string; var SubKeys: TStringList): boolean; var Reg: TRegistry; begin SubKeys := nil; Reg := TRegistry.create; try if Reg.OpenKey(ARegStr, false) then begin SubKeys := TStringList.Create; Reg.GetKeyNames(SubKeys); Reg.CloseKey; end; finally Reg.free; end; Result := SubKeys <> nil; end;
What result do you get? Is Firebird installed on your PC Have you checked the registry values using RegEdit?
Your registry function doesn't work. I've updated my answer with a function that works perfectly on 3 machines I have at my disposal with Firebird installed on them.
In regedt I do not have that key. I found just HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\SharedDLLs\aliases.conf but as you know an other computer with other stupid windows this key will not work. If I could search the key by using just part name of key for example just "aliases.conf" then would be great.
Yes, yes I have installed Firebird. The result was Nil.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.