Open a .pdf file from C++ Win32 Console Application

In summary, the speakers discuss opening a .pdf or .exe file from a Visual C++ 2008 express edition program. One person was able to receive help outside of the forum and successfully accomplish their task. The other person asks for the code or links used to achieve this, as they have been unsuccessful so far. They mention using a basic method of searching for files using a .txt file and a string.
  • #1
CFDFEAGURU
783
10
Hello all,

Does anyone know how to open a .pdf file (or a .exe) file from a Visual C++ 2008 express edition program?

What I am trying to do is to have the user enter a number that corresponds to a certain .pdf file and have that .pdf file open for the user to read,save,print, etc ...

Thanks
Matt
 
Technology news on Phys.org
  • #2
Never mind all,

I received some help from outside the forum and all is well.

Thanks
Matt
 
  • #3
Matt,

Can you please send me the code that you used or the links of the sites from where you received help, because I'm also trying to do the same but so far have only been successful in searching - that too from the most basic method (the one where you input all files in a .txt file use a string to match and then let the user know whether the file exists or not)

Any help will be really appreciated.

Waiting for your reply

Regards

Zain
 

Related to Open a .pdf file from C++ Win32 Console Application

1. How do I open a .pdf file from a C++ Win32 Console Application?

To open a .pdf file from a C++ Win32 Console Application, you will first need to include the #include and #include header files in your code. Then, you can use the ShellExecute function with the open verb and the file path of the .pdf file as parameters. This will open the .pdf file using the default program associated with .pdf files on the user's computer.

2. Can I specify a specific program to open the .pdf file instead of the default program?

Yes, you can specify a specific program to open the .pdf file by using the ShellExecute function with the open verb, the file path of the program, and the file path of the .pdf file as parameters. This will open the .pdf file using the specified program.

3. How do I handle errors when opening a .pdf file?

You can handle errors when opening a .pdf file by checking the return value of the ShellExecute function. If the return value is greater than 32, it means the function was successful. If the return value is less than or equal to 32, it means an error occurred. You can use the GetLastError function to get the error code and use it to determine the cause of the error.

4. Can I open a .pdf file without using the default program or a specific program?

Yes, you can open a .pdf file without using the default program or a specific program by using the ShellExecute function with the open verb, NULL as the second parameter, and the file path of the .pdf file as the third parameter. This will open the .pdf file using the default program associated with .pdf files, but without the other program's features (such as printing or saving).

5. Can I open a .pdf file from a C++ Win32 Console Application on different operating systems?

Yes, you can open a .pdf file from a C++ Win32 Console Application on different operating systems as long as the ShellExecute function is supported on those operating systems. However, the default program associated with .pdf files may vary between different operating systems, so the result may not be the same on each system.

Similar threads

  • Programming and Computer Science
Replies
22
Views
977
  • Programming and Computer Science
Replies
6
Views
9K
  • Programming and Computer Science
Replies
8
Views
925
  • Programming and Computer Science
Replies
11
Views
2K
  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
7
Views
2K
  • Programming and Computer Science
Replies
4
Views
5K
  • Programming and Computer Science
Replies
6
Views
2K
  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
5
Views
6K
Back
Top