Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Trucos (https://www.clubdelphi.com/foros/forumdisplay.php?f=52)
-   -   Buscar Ejecutable asociado a extensión (https://www.clubdelphi.com/foros/showthread.php?t=80483)

Casimiro Notevi 20-06-2006 15:22:35

Buscar Ejecutable asociado a extensión
 
Código Delphi [-]
function BuscarEjecutableAsociado( Fichero:string ):string;
var
   Ejecutable:Pchar;
begin
   GetMem(Ejecutable,200);
   FindExecutable(Pchar(Fichero),nil,Ejecutable);
   Result:=String(Ejecutable);
   FreeMem(Ejecutable,200);
end;

Y la llamada sería algo así como:
Código Delphi [-]
cPrograma := BuscarEjecutableAsociado( 'c:\libros\CaraOcultaDelphi.pdf' );

Esto devolvería algo así: 'C:\Archivos de programa\Adobe\Acrobat 7.0\Reader\AcroRd32.exe'

seoane 20-06-2006 15:34:16

Solo añadir que si el archivo no existe, devolvera un string vacio. Es decir, si 'c:\libros\CaraOcultaDelphi.pdf' no es un archivo real la funcion devolvera un string vacio

Neftali [Germán.Estévez] 20-06-2006 16:12:35

Sólo añadir que se debe poner en el uses la unit: ShellAPI


La franja horaria es GMT +2. Ahora son las 16:20:30.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi