You don’t need all of the jumping-through hoops you’re doing. Windows will find the application associated with PDF files for you.
procedure TForm1.Button1Click(Sender: TObject);
var
s: String;
Ret: DWord;
begin
s := 'C:\MyFiles\MyFile.pdf';
Ret := ShellExecute(Handle, nil, PChar(s), nil, nil, SW_SHOW);
if Ret < 32 then
ShowMessage(SysErrorMessage(GetLastError));
end;
Note: Normally you should never call a WinAPI function without checking the return value. In this case, you’ll know if it didn’t work because the PDF won’t open.
1
solved Delphi XE8 Load PDF File