Fórum Abrir arquivos no Delphi #209722
27/01/2004
0
Preciso de um código para abrir um arquivo no Acrobat Reader quando clicar em um botão no form do delphi.
O mesmo quando clicar em um outro botão abrir um slide do Power Point.
Quem poder me ajudar agradeço!
Obrigado!
Stéfano :shock:
[color=red:ddae33adc3][b:ddae33adc3]Tópico editado(Beppe): Título desconforme com as regras de conduta[/b:ddae33adc3][/color:ddae33adc3]
O mesmo quando clicar em um outro botão abrir um slide do Power Point.
Quem poder me ajudar agradeço!
Obrigado!
Stéfano :shock:
[color=red:ddae33adc3][b:ddae33adc3]Tópico editado(Beppe): Título desconforme com as regras de conduta[/b:ddae33adc3][/color:ddae33adc3]
Thesanto
Curtir tópico
+ 0
Responder
Posts
27/01/2004
Oberdan
Abrir arquivos com aplicativo associado
Inclua a unit SHELLAPI na clausula uses do seu form.
procedure TForm1.ExecFile(F: String);
var
r: String;
begin
case ShellExecute(Handle, nil, PChar(F), nil, nil, SW_SHOWNORMAL) of
ERROR_FILE_NOT_FOUND: r := ´The specified file was not found.´;
ERROR_PATH_NOT_FOUND: r := ´The specified path was not found.´;
ERROR_BAD_FORMAT: r := ´The .EXE file is invalid (non-Win32 .EXE or error in .EXE image).´;
SE_ERR_ACCESSDENIED: r := ´Windows 95 only: The operating system denied access to the specified file.´;
SE_ERR_ASSOCINCOMPLETE: r := ´The filename association is incomplete or invalid.´;
SE_ERR_DDEBUSY: r := ´The DDE transaction could not be completed because other DDE transactions were being processed.´;
SE_ERR_DDEFAIL: r := ´The DDE transaction failed.´;
SE_ERR_DDETIMEOUT: r := ´The DDE transaction could not be completed because the request timed out.´;
SE_ERR_DLLNOTFOUND: r := ´Windows 95 only: The specified dynamic-link library was not found.´;
SE_ERR_NOASSOC: r := ´There is no application associated with the given filename extension.´;
SE_ERR_OOM: r := ´Windows 95 only: There was not enough memory to complete the operation.´;
SE_ERR_SHARE: r := ´A sharing violation occurred.´;
else
Exit;
end;
ShowMessage(r);
end;
Utilize a função assim:
procedure TForm1.Button1Click(Sender: TObject);
begin
ExecFile(´c:\windows\ladrilhos.bmp´);
end;
Inclua a unit SHELLAPI na clausula uses do seu form.
procedure TForm1.ExecFile(F: String);
var
r: String;
begin
case ShellExecute(Handle, nil, PChar(F), nil, nil, SW_SHOWNORMAL) of
ERROR_FILE_NOT_FOUND: r := ´The specified file was not found.´;
ERROR_PATH_NOT_FOUND: r := ´The specified path was not found.´;
ERROR_BAD_FORMAT: r := ´The .EXE file is invalid (non-Win32 .EXE or error in .EXE image).´;
SE_ERR_ACCESSDENIED: r := ´Windows 95 only: The operating system denied access to the specified file.´;
SE_ERR_ASSOCINCOMPLETE: r := ´The filename association is incomplete or invalid.´;
SE_ERR_DDEBUSY: r := ´The DDE transaction could not be completed because other DDE transactions were being processed.´;
SE_ERR_DDEFAIL: r := ´The DDE transaction failed.´;
SE_ERR_DDETIMEOUT: r := ´The DDE transaction could not be completed because the request timed out.´;
SE_ERR_DLLNOTFOUND: r := ´Windows 95 only: The specified dynamic-link library was not found.´;
SE_ERR_NOASSOC: r := ´There is no application associated with the given filename extension.´;
SE_ERR_OOM: r := ´Windows 95 only: There was not enough memory to complete the operation.´;
SE_ERR_SHARE: r := ´A sharing violation occurred.´;
else
Exit;
end;
ShowMessage(r);
end;
Utilize a função assim:
procedure TForm1.Button1Click(Sender: TObject);
begin
ExecFile(´c:\windows\ladrilhos.bmp´);
end;
Responder
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)