Subject | Re: [IBO] Re: Check if IB server is running |
---|---|
Author | Luiz Alves |
Post date | 2000-11-28T20:29:16Z |
Here is from ibconsole source:
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
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;
Luiz.
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
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;
Luiz.
----- Original Message -----
From: <gerbreown@...>
To: <IBObjects@egroups.com>
Sent: Tuesday, November 28, 2000 10:18 AM
Subject: [IBO] Re: Check if IB server is running
> Thanks, I'll give that a try. Do you know how I can then shut down
> the server when my application quits?
>
>
>
> --- In IBObjects@egroups.com, "Luiz Alves" <cprmlao@i...> wrote:
> > You could try what ib_console does:
> >
> > Here is :
> >
> > function IsIBRunning(): boolean;
> > begin
> > if GetWindow(GetDesktopWindow,GW_HWNDNEXT)=
> FindWindow('IB_Server',
> > 'InterBase Server') then
> > result := false
> > else
> > result := true;
> > 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
> > 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;
> >
> > Luiz.
> > ----- Original Message -----
> > From: <gerbreown@m...>
> > To: <IBObjects@egroups.com>
> > Sent: Monday, November 27, 2000 5:57 PM
> > Subject: [IBO] Check if IB server is running
> >
> >
> > > Jason,
> > >
> > > Is there an IBO component that I can use from within my Delphi
> > > application to see if the local IB server is currently running?
> If it
> > > is not running then I want to start it before my application tries
> to
> > > access any databases. I then want shut it down, if I started it,
> just
> > > before my applicition quits. If it was running when my
> application
> > > started then I would leave it run at appliction quit time.
> > >
> > > Thanks,
> > >
> > > Gerald S. Brown
> > >
> > >
> > >
> > >
> > >
>
>
>
>
>