[firebase-br] Saber se o Firebird esta rodando ou não!

Anticlei Scheid clei em geous.com.br
Seg Abr 21 08:21:38 -03 2008


Bom dia.

Se for Delphi anota aí :

Quando inicio o aplicativo coloco este trecho no FormShow, ou onde você 
preferir
...
    //coloca o firebird no ar se não estiver
    if not EXE_Running('fbguard.exe',False) then
    begin
      if (Win32Platform <> VER_PLATFORM_WIN32_NT) then //não é XP, 2000 ou 
2003
      begin
        StatusBar.SimpleText:= 'Carregando o servidor de Banco de Dados 
Firebird ...';
        Application.ProcessMessages;
        if 
FileExists(ArquivosDeProgramas+'\Firebird\Firebird_1_5\bin\fbguard.exe') 
then
        begin
          ArqExec:= TFileRun.Create(self);
          with ArqExec do
          begin
            Directory:= ArquivosDeProgramas+'\Firebird\Firebird_1_5\bin';
            FileName:= 'fbguard.exe';
            Parameters:= '-a';
            Operation:= 'open';
            ShowCmd:= scShowDefault;
            Execute;
            Application.ProcessMessages;
          end;
          Sleep(2000);
        end
        else
          raise Exception.Create(
            'Não foi possível carregar o servidor de Banco de Dados 
Firebird,'+#13+#10+
            'pois não foi encontrado o arquivo'+#13+#10+
            '"'+ArquivosDeProgramas+'\Firebird\Firebird_1_5\bin\fbguard.exe"');
      end
      else
        raise Exception.Create(
          'Houve algum erro na instalação do servidor de Banco de Dados 
Firebird,'+#13+#10+
          'pois o serviço "fbguard" não está carregado.'+#13+#10+
          'Tente instalar novamente o Firebird.');
   end;

...


Depois tem a função EXE_Running que usei no trecho e que peguei numa outra 
lista de discussão :

function EXE_Running(FileName: string; bFullpath: Boolean):Boolean;
var
  i: Integer;
  MyProcList: TStringList;
begin
  MyProcList:= TStringList.Create;
  try
    GetProcessList(MyProcList);
    Result := False;
    if MyProcList = nil then Exit;
    for i := 0 to MyProcList.Count - 1 do
    begin
      if not bFullpath then
      begin
        if CompareText(ExtractFileName(MyProcList.Strings[i]),FileName) = 0 
then
          Result := True
      end
      else if CompareText(MyProcList.strings[i], FileName) = 0 then
        Result := True;
      if Result then
        Break;
    end;

  finally
    MyProcList.Free;
  end;
end;

Espero ter ajudado.
Se não servir exatamente, já é uma boa pista.


----- Original Message ----- 
From: "José Luiz" <zeluizdala em terra.com.br>
To: <lista em firebase.com.br>
Sent: Sunday, April 20, 2008 8:52 PM
Subject: [firebase-br] Saber se o Firebird esta rodando ou não!


Ola

Gostaria de saber se alguém uma rotina que eu possa usar nos meus programas 
que identifique se o firebird esta ou não ativo/rodando na máquina que vai 
executar o programa, caso não esteja execute. Tem como fazer isso?

Grato.

______________________________________________
FireBase-BR (www.firebase.com.br) - Hospedado em www.locador.com.br
Para saber como gerenciar/excluir seu cadastro na lista, use: 
http://www.firebase.com.br/fb/artigo.php?id=1107
Para consultar mensagens antigas: http://firebase.com.br/pesquisa





Mais detalhes sobre a lista de discussão lista