Click here to Skip to main content
15,905,607 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to open pdf file from vc++. when i click on to the button the pdf file should get open in adobe. can any1 help me
Posted

Look here:
http://www.experts-exchange.com/Programming/System/Windows__Programming/MFC/Q_20486767.html[^]
It says:
Use ShellExecute with the open parameter on the pdf file. This will open the pdf file in whatever viewer the user has associated with pdf.
ShellExecute(NULL, "open", "C:\\Program Files\\Adobe\\Acrobat 5.0\\Help\\ENU\\DocBox.pdf", NULL, NULL, SW_SHOW);

Try!
 
Share this answer
 
ty ...it worked fine ..thanks for the help
one addition to that ...if ShellExecute giving u any error then just #include "shellapi.h" :-D
 
Share this answer
 
Comments
Sandeep Mewara 28-Jun-10 5:24am    
Good to know it helped. If an answer resolves your issue then you should mark that as an answer for future references for other people.
amarasat 10-Feb-11 9:25am    
This has worked for me without any errors:

ShellExecute(NULL, _T("open"), _T("C:\\Program Files\\...."), NULL, NULL, SW_SHOW);

But i am having a problem, what if the user doesn't have an associated viwer for the PDF

1.) In this case what would be the default PDF reader the ShellExecute will pick to open the PDF

2.) What if the user doesn't have any acrobat or PDF reader or PDF viewer installed? How do i ahndle this case?
Jefferson Daniel 18-May-12 20:48pm    
Iv tried ShellExecute, Shell, and #include <shellapi.h> and the minute I add the #include <shellapi.h> my errors jumps to like 230. the whole program goes nuts. I'm using Vb 2010 and coding C++. if i dont add any #include i get shellexcute is not a identifier.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900