Not sure if this is the correct approach to solving problem (maybe better to see why its consuming so much resources in the first place) but here is some code to start the Interbase Service programitically :
* 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 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;
And just 2 other code snippets that may be useful :
* StopService ( )
*
****************************************************************
* Author: Unknown
* Date: Sept 2003
*
* Input:
*
* Return: true/False (success)
*
* Description: Stops a service on Windows XP/NT/2000
*
*****************************************************************}
function ServiceStop(aMachine,aServiceName : string ) : boolean;
// aMachine is UNC path or local machine if left empty
var
h_manager,h_svc : SC_Handle;
svc_status : TServiceStatus;
dwCheckPoint : DWord;
begin
h_manager:=OpenSCManager(PChar(aMachine),nil,
SC_MANAGER_CONNECT);
if h_manager > 0 then
begin
h_svc := OpenService(h_manager,PChar(aServiceName),
SERVICE_STOP or SERVICE_QUERY_STATUS);
if h_svc > 0 then
begin
if(ControlService(h_svc,SERVICE_CONTROL_STOP,
svc_status))then
begin
if(QueryServiceStatus(h_svc,svc_status))then
begin
while(SERVICE_STOPPED <> svc_status.dwCurrentState)do
begin
dwCheckPoint := svc_status.dwCheckPoint;
Sleep(svc_status.dwWaitHint);
if(not QueryServiceStatus(h_svc,svc_status))then
begin
// couldn't check status
break;
end;
if(svc_status.dwCheckPoint < dwCheckPoint)then
break;
end;
end;
end;
CloseServiceHandle(h_svc);
end;
CloseServiceHandle(h_manager);
end;
Result := SERVICE_STOPPED = svc_status.dwCurrentState;
end;
Check if service is already running :
Function IsIBRunning(): boolean;
Begin
If GetWindow(GetDesktopWindow, GW_HWNDNEXT) = FindWindow('IB_Server',
'InterBase Server') Then
result := False
Else
result := True;
End;
As you may guess, this represents code I have found on this issue and is from various sources. You will need to change as you feel necessary.
Hope this helps..
Opp.