Opening PDF files

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Mar 2008
Posts: 42
Reputation: marcosjp is an unknown quantity at this point 
Solved Threads: 0
marcosjp marcosjp is offline Offline
Light Poster

Opening PDF files

 
0
  #1
Feb 6th, 2009
Hello there!

I need to open PDF files from a C program. So, initially I have this solution:

  1. ShellExecute(GetDesktopWindow(), "open", "c:\somefolder\myFile.pdf", NULL, NULL, SW_SHOWNORMAL);

However, this code has its limitations:

1. It works, but a shell window comes up and closes when opening the PDF file. Is there a way to avoid this? Maybe using another programming language?

2. This is Windows specific - I'd like to be able to do it in Linux as well.

3. What is the advantage of using this to using this one?

  1. system("start c:\\somefolder\\myFile.pdf");

Thanks very much for any help!

[]s
Marcos
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 2,001
Reputation: ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of 
Solved Threads: 343
ArkM's Avatar
ArkM ArkM is offline Offline
Postaholic

Re: Opening PDF files

 
0
  #2
Feb 6th, 2009
1. It DOES NOT work because you forgot to double backslashes in the file name string literal (see point #3 example in your snippet).
2. ? No platform-independent solution.
3. ShellExecute is a direct way to do the same job...
Last edited by ArkM; Feb 6th, 2009 at 11:49 am.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 42
Reputation: marcosjp is an unknown quantity at this point 
Solved Threads: 0
marcosjp marcosjp is offline Offline
Light Poster

Re: Opening PDF files

 
0
  #3
Feb 6th, 2009
Originally Posted by ArkM View Post
1. It DOES NOT work because you forgot to double backslashes in the file name string literal (see point #3 example in your snippet).
You're right. Actually my original file did have different letters after the slash ahd DID work. Anyway thanks for the tip.

Originally Posted by ArkM View Post
2. ? No platform-independent solution.
I will ask this in a different way. Forget Windows. How do I get the same results in a) Linux and b) Mac?

And the first question, how to avoid the shell window, is actually the most important right now. I know there is a solution,... Any hints?

Thanks

[]s
Marcos
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 476
Reputation: nucleon has a spectacular aura about nucleon has a spectacular aura about 
Solved Threads: 91
nucleon's Avatar
nucleon nucleon is offline Offline
Posting Pro in Training

Re: Opening PDF files

 
0
  #4
Feb 6th, 2009
There should be an option to not create a console window for a "console" program. There is in Dev-C++ (with gcc).
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 42
Reputation: marcosjp is an unknown quantity at this point 
Solved Threads: 0
marcosjp marcosjp is offline Offline
Light Poster

Re: Opening PDF files

 
0
  #5
Feb 6th, 2009
Great! Actually, there is:

Toos->Compiler Options->Settings->Links->Do not create a console windows->Yes.

Thank you.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC