943,699 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Marked Solved
  • Views: 623
  • C RSS
Feb 6th, 2009
0

Opening PDF files

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
marcosjp is offline Offline
42 posts
since Mar 2008
Feb 6th, 2009
0

Re: Opening PDF files

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.
Reputation Points: 1234
Solved Threads: 347
Postaholic
ArkM is offline Offline
2,001 posts
since Jul 2008
Feb 6th, 2009
0

Re: Opening PDF files

Click to Expand / Collapse  Quote originally posted by ArkM ...
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.

Click to Expand / Collapse  Quote originally posted by ArkM ...
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
Reputation Points: 10
Solved Threads: 0
Light Poster
marcosjp is offline Offline
42 posts
since Mar 2008
Feb 6th, 2009
0

Re: Opening PDF files

There should be an option to not create a console window for a "console" program. There is in Dev-C++ (with gcc).
Reputation Points: 163
Solved Threads: 91
Posting Pro in Training
nucleon is offline Offline
476 posts
since Oct 2008
Feb 6th, 2009
0

Re: Opening PDF files

Great! Actually, there is:

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

Thank you.
Reputation Points: 10
Solved Threads: 0
Light Poster
marcosjp is offline Offline
42 posts
since Mar 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Correction
Next Thread in C Forum Timeline: Function to grab User/Password combinations from a file





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC