Subject Re: [IBO] Start Interbase when my IBO App runs?
Author Andreas Pohl
There was a thread by someone else on this list about this topic. Please see
attached code snipped.

Mit freundlichem Gruss & Best Regards

Andreas Pohl
apohl@...
www.ibp-consult.com

function IsIBRunning(): boolean;
begin
if GetWindow(GetDesktopWindow,GW_HWNDNEXT)= FindWindow('IB_Server',
'InterBase Server') then
result := false
else
result := true;
end;

function StopServer(): boolean;
var
lHWND: HWND;
lVersion: DWORD;
lRegistry: TRegistry;
lEXEName: string;
lArray: array[0..255] of char;
begin
result := false;
lRegistry := TRegistry.Create;
try
Screen.Cursor := crHourglass;
lVersion := OSVersionInfo();
if lVersion = VER_PLATFORM_WIN32_NT then
begin
lRegistry.RootKey := HKEY_LOCAL_MACHINE;
// if not
lRegistry.OpenKey('Software\Borland\InterBase\CurrentVersion',False) then
if not lRegistry.OpenKey('Software\InterBase
Corp\InterBase\CurrentVersion',False) then
ShowMessage('InterBase server is not installed on your system.')
else
lEXEName
:=Format('%s\%s',[lRegistry.ReadString('ServerDirectory'),'instsvc.exe
stop']);

if WinExec(StrPCopy(lArray,lEXEName), 2) > 31 then
result := true;
end
else if lVersion = VER_PLATFORM_WIN32_WINDOWS then
begin
lHWND:= FindWindow('IB_Server', 'InterBase Server');
if PostMessage(lHWND, WM_CLOSE, 0, 0)<> Null then
result := true;
Application.ProcessMessages;
end;
finally
lRegistry.Free;
Screen.Cursor := crDefault;
end;
end;

function StartGuardian(): boolean;
var
lRegistry: TRegistry;
lEXEName: string;
lArray: array[0..255] of char;
begin
result := false;
lRegistry := TRegistry.Create;
try
Screen.Cursor := crHourglass;
lRegistry.RootKey := HKEY_LOCAL_MACHINE;
// if not
lRegistry.OpenKey('Software\Borland\InterBase\CurrentVersion',False) then
if not lRegistry.OpenKey('Software\InterBase
Corp\InterBase\CurrentVersion',False) then
ShowMessage('InterBase server is not installed on your computer.')
else
lEXEName :=
Format('%s\%s',[lRegistry.ReadString('ServerDirectory'),'ibguard.exe']);
finally
if WinExec(StrPCopy(lArray,lEXEName),1) > 31 then
result := true;
lRegistry.Free;
Screen.Cursor := crDefault;
end;
end;

function OSVersionInfo():Integer;
var os:TOSVERSIONINFO;
begin
os.dwOSVersionInfoSize:=sizeof(os);
GetVersionEx(os);
result:=os.dwPlatformId;
end;