Solved

Adobe reader can't open pdf file from shellexecute

Posted on 2007-11-29
6
2,852 Views
Last Modified: 2010-04-21
I use a shellexecute command to open a pdf document from a delphi app. After upgrading Adobe Reader to 8.1.1 it no longer works and I get the error message:

There was an error opening this document. The file cannot be found.

The file can be opened from within Adobe Reader without any problems. It worked fine before 8.1.1.

Andy help would be appreciated. Thanks

Open in new window

0
Comment
Question by:Link-HRSystems
  • 3
  • 2
6 Comments
 
LVL 21

Expert Comment

by:ziolko
Comment Utility
any code sample would be appreciated

ziolko.
0
 

Author Comment

by:Link-HRSystems
Comment Utility
Here you go if it helps.

Thanks
filename := ExtractFilePath(Application.ExeName)+ 'Documentation\'+ pdffile;
 

sExecutable := ShellFindExecutable(filename,ExtractFilePath(filename));
 

ShellExecute(hInstance, nil, PChar(sExecutable), pChar(filename), nil,

        SW_SHOW);

Open in new window

0
 
LVL 18

Expert Comment

by:Johnjces
Comment Utility
Would you please try

if shellexecute(handle, nil, Pchar(filename), nil, nil, SW_SHOW) < 32 then
    ShowMessage('Unable to open file');

As long as the .pdf extension is properly registered, (or any other extension) this should open Adobe and the file so there is no need of specifying the executable.

Therfor filename has to be the complete path filename and .pdf extension.

John
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 21

Accepted Solution

by:
ziolko earned 125 total points
Comment Utility
first of check if ShellFindExecutable() returns correct path
then try this:
ShellExecute(hInstance, 'open', PChar(sExecutable), pChar(filename), nil,  SW_SHOW);
or
ShellExecute(hInstance, 'open', nil, pChar(filename), nil,  SW_SHOW);

ziolko.
0
 

Author Comment

by:Link-HRSystems
Comment Utility
Thanks for the replies.

John
I can open the file using just the filename but I need to specify page number as well, that is why I was using Parameters.

Does anyone have the syntax to specify a page number as well?

Thanks
0
 

Author Closing Comment

by:Link-HRSystems
Comment Utility
This did answer my question wasn't my full issue, my mistake I will post another question.

Thanks
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video discusses moving either the default database or any database to a new volume.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now