Subject Re: Detect if Firebird is Running
Author paulfilmer
--- In IBObjects@yahoogroups.com, "ra8009" <ra8009@y...> wrote:
> How can I detect whether or not Firebird is running?

We do it in Windows by checking whether the service is running. Check
out http://www.delphifaq.com/fq/q2121.shtml for the basic idea:


uses Windows, WinSvc;

function ServiceIsRunning(sMachine, sService: String) : Boolean;
var
schm,
schs: SC_Handle;
ss: TServiceStatus;
begin
schm := OpenSCManager(PChar(sMachine), nil, SC_MANAGER_CONNECT);
if (schm>0) then
begin
schs := OpenService(schm, PChar(sService), SERVICE_QUERY_STATUS);
if (schs>0) then
begin
QueryServiceStatus(schs, ss);
CloseServiceHandle(schs);
end;
CloseServiceHandle(schm);
end;
Result := SERVICE_RUNNING=ss.dwCurrentState;
end;


Call it like ServiceIsRunning('\\MyMachineName','InterbaseServer').

The two FB services running on my computer here are:
FirebirdGuardianDefaultInstance
FirebirdServerDefaultInstance