GARANTIR DESCONTO

Fórum Detectar Firebird no Vista #368291

10/02/2009

0

Como posso saber se o Firebird está rodando no Windows Vista? No XP eu consigo fazer, mas o código não dá certo para o Windows Vista. Segue o código que eu utilizo.

function CheckForMutexes(Mutexes: String): Boolean;
    { Returns True if any of the mutexes in the comma-separated Mutexes string    
      exist }                                                                     
var                                                                               
    I: Integer;                                                                   
    M: String;                                                                    
    H: THandle;                                                                   
begin                                                                             
    Result := False;                                                              
    repeat                                                                        
        I := Pos(´,´, Mutexes);                                                   
        if I = 0 then    
        begin                                                         
            I := Maxint;
        end;
        M := Trim(Copy(Mutexes, 1, I-1));                                         
        if M <> ´´ then                                                           
        begin                                                                     
            H := OpenMutex(SYNCHRONIZE, False, PChar(M));                         
            if H <> 0 then                                                        
            begin                                                                 
                CloseHandle(H);                                                   
                Result := True;                                                   
                Break;                                                            
            end;                                                                  
        end;                                                                      
        Delete(Mutexes, 1, I);                                                    
    until Mutexes = ´´;                                                           
end;

function FirebirdDefaultServerRunning2(N1, N2, N3, N4, N5: String): string;
var
    Handle: Integer;
    mutex_found: boolean;
begin
    result := ´´;
    //Look for a running version of Firebird 1.5 or later
//    Handle := FindWindowByClassName(´FB_Disabled´);
    Handle := FindWindow(PChar(N1){´FB_Disabled´}, nil);
    if ( Handle = 0 ) then
    begin
        Handle := FindWindow(PChar(N2){´FB_Server´}, nil);
    end;
    if ( Handle = 0 ) then
    begin
        Handle := FindWindow(PChar(N3){´FB_Guard´}, nil);
    end;

    if (Handle > 0) then
    begin
        result := ´1.5´;
    end
    else 
    begin
        mutex_found := CheckForMutexes(PChar(N4){´FirebirdGuardianMutex,FirebirdServerMutex´});
        if mutex_found then
        begin
            result := ´2.0´;
        end
        else 
        begin
            mutex_found := CheckForMutexes(PChar(N5){´FirebirdGuardianMutexDefaultInstance,FirebirdServerMutexDefaultInstance´});
            if mutex_found then
            begin
                result := ´2.1´
            end;                           
        end;    
    end;
end;


E chamo a função da seguinte forma:
Is_FB_Running := (´2.1´ = FirebirdDefaultServerRunning2(´FB_Disabled´, ´FB_Server´, ´FB_Guard´, ´FirebirdGuardianMutex,FirebirdServerMutex´, ´FirebirdGuardianMutexDefaultInstance,FirebirdServerMutexDefaultInstance´))


Alguém pode me dar uma luz??


Daniel Grillo

Daniel Grillo

Responder

Posts

11/02/2009

Daniel Grillo

Up


Responder

Gostei + 0

12/02/2009

Daniel Grillo

up


Responder

Gostei + 0

13/02/2009

Daniel Grillo

Ninguém???


Responder

Gostei + 0

19/02/2009

Daniel Grillo

Alguém poderia me ajudar???


Responder

Gostei + 0

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar