Hi Eion,

It sounds like you're looking for FindExecutable. Apparently there's some 
small quirk in the WinAPI call, so the code (ShellFindExecutable) below 
comes in handy. Thanks to Petr Vones (Team JEDI) for that.

I use it like this:
uses ShellAPI
...
   strApp := ShellFindExecutable('C:\test.pdf', '');
   ShellExecute(Application.Handle, 'OPEN', pchar(strApp), 
pchar(strDocToOpenIfAny), nil, SW_SHOW);

Just make sure there is actually a 'C:\test.pdf' or whatever - even if you 
just create one in name only. Although I'd be interested in a work-around 
to that if anyone knows of one.

Ed


----------
function ShellFindExecutable(const FileName, DefaultDir: string): string;
var
   Res: HINST;
   Buffer: array[0..MAX_PATH] of Char;
   P: PChar;
begin
   FillChar(Buffer, SizeOf(Buffer), #0);
   if DefaultDir = '' then P := nil else P := PChar(DefaultDir);
   Res := FindExecutable(PChar(FileName), P, Buffer);
   if Res > 32 then
   begin
     P := Buffer;
     while PWord(P)^ <> 0 do
     begin
       if P^ = #0 then // FindExecutable replaces #32 with #0
         P^ := #32;
       Inc(P);
     end;
     Result := Buffer;
   end else
     Result := '';
end;


At 12:46 04/07/2001 +1200, you wrote:
>Hi
>
>We want to start an external program from within an Delphi app. The only way
>we have found how to do it so far is via
>WINEXEC but this we can get this to work properly is but physically putting
>the full programs exe path in for it to start.
>The file type under explorer indicates that the extension of the file we
>wish to load is associated with the application i.e. PDF = acrobat reader.
>Is there another way, or other command, to available to start this app
>without having to have the full exe path in the program,
>as the application may not be in the same location on every PC.
>
>Eion McIntosh
>PPCS Ltd
>---------------------------------------------------------------------------
>     New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
>To UnSub, send email to: [EMAIL PROTECTED]
>with body of "unsubscribe delphi"

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"

Reply via email to