arquivo.jar + delphi

Delphi

25/01/2018

Como faço para chegar se um arquivo .jar esta aberto pelo delphi?
Wilton Júnior

Wilton Júnior

Curtidas 0

Respostas

Natanael Ferreira

Natanael Ferreira

25/01/2018

Teste esta função:

function arquivoAberto(arquivo: string): Boolean;
var
  StreamArquivo: TFileStream;
begin
  if not FileExists(arquivo) then
    raise Exception.CreateFmt('O arquivo "%s" não existe', [arquivo])
  else
    try
      StreamArquivo := TFileStream.Create(arquivo, fmShareExclusive and fmOpenRead);
      StreamArquivo.Free;
      result := False;
    except
      result := True;
    end;
end;

Exemplo de uso:

if arquivoAberto('C:\\Arquivo.jar') then
 Showmessage('Arquivo aberto.')
else
 Showmessage('Arquivo fechado');
GOSTEI 0
Wilton Júnior

Wilton Júnior

25/01/2018

Deu certo obrigado
GOSTEI 0
POSTAR