Subject Re: [IBO] Re: How can I automatically start Interbase when my IBO App runs?
Author delphiman
Thanks mate!

delphiman@...
Mobile: (Australia) 0407-007-159
Phone: ( Australia (02) 6041-1036)
ICQ 63345769



----- Original Message -----
From: gsbrown@...
To: IBObjects@yahoogroups.com
Sent: Friday, September 14, 2001 5:52 AM
Subject: [IBO] Re: How can I automatically start Interbase when my IBO App runs?


--- In IBObjects@y..., "Warren Postma" <warren-postma@h...> wrote:
> How can I get Interbase, if not already running, to start
automatically, when
> my IBO application starts up.
> (Currently using IBO 3.6)
>
Warren,

Below is the code that I use to start IB if it is not running:

Procedure TDO_DM.DataModuleCreate(Sender: TObject);
Var
lRegistry: TRegistry;
i: Integer;
fDB, fHlp, lEXEName: String;
Begin
If Not IsIBRunning Then
Begin
StartServer;
End;
End;

Function TDO_DM.IsIBRunning(): boolean;
Begin
If GetWindow(GetDesktopWindow, GW_HWNDNEXT) =
FindWindow('IB_Server',
'InterBase Server') Then
result := False
Else
result := True;
End;

{****************************************************************
*
* S t a r t S e r v e r ( )
*
****************************************************************
* Author: The Client Server Factory Inc.
* Date: March 1, 1999
*
* Input:
*
* Return:
*
* Description:
*
*****************************************************************
* Revisions:
*
*****************************************************************}

Function TDO_DM.StartServer(): boolean;
Var
lRegistry: TRegistry;
lStartUpInfo: STARTUPINFO;
lSecurityAttr: SECURITY_ATTRIBUTES;
lProcessInfo: PROCESS_INFORMATION;
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
ShowMessage('InterBase server is not installed on your system.')
Else
lEXEName := Format('%s%s -a',
[lRegistry.ReadString('RootDirectory'),
'bin\ibserver.exe']);
ZeroMemory(@lStartUpInfo, SizeOf(lStartUpInfo));
lStartUpInfo.cb := SizeOf(lStartUpInfo);
lSecurityAttr.nLength := SizeOf(lSecurityAttr);
lSecurityAttr.lpSecurityDescriptor := Nil;
lSecurityAttr.bInheritHandle := True;
If CreateProcess(Nil, StrPCopy(lArray, lEXEName), @lSecurityAttr,
Nil,
False, 0, Nil,
Nil, lStartUpInfo, lProcessInfo) <> Null Then
result := True
Else
ShowMessage('The server could not be started.')
Finally
lRegistry.Free;
Screen.Cursor := crDefault;
End;
End;

I found this code somewhere awhile ago so I can't take credit for it.
Hope you find it useful. I also have the code somewhere to start the
IBGuardian if you would like to see that also.

Gerald S. Brown





Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/




[Non-text portions of this message have been removed]