Need to know how to open a help file from C++

I've written a program for my assignment and well it working fine but what I can't get my head around is how to call a CHM or a PDF file and display it and return back to the program.

I use the below function to display a text from a text file but it doesn't look professional I use a case operator to make menu which will call the below function I could use that to open the chm or PDF with out leaving the main window like in any other GUL based program hope you guys can help me.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
  //This function opens a text file and display the content as the help document
void hlpDoc(){

	system("CLS");
	string txtHlp;
	ifstream hlpFile;
	hlpFile.open("hlpDoc.txt");

	if(hlpFile.is_open()){
		while(hlpFile.good()){

			getline(hlpFile, txtHlp);
			cout<<txtHlp<<endl;
		}
	}

	hlpFile.close();
	entLine();
	pause();

}


And this site helped me a lot during my studies thank you guys for helping me this place is a haven for noobs like us.
Last edited on
Unless you write a lot of code, you will not be able to open a .chm or a .pdf and show it on the screen.

What you need to do is look at the system() call and call the appropriate program to open these types of files.
Kooth Thx, No I don;t want to display the file inside the same screen as the program what I want to do is that when I enter the number specified for help the chm or PDF opens up in it own supported program.

I've no idea to integrate the PDF or the CHM program viewers in to the CLI interface (That takes too much time and Time I don't have).

Also I was hoping that I could do it with out System() 'cos System() is evil
Last edited on
Sorry if I'm posting it in the wrong forum but did post this in Beginners but didn't get any help please can some one help me with this.
Last edited on
Also I was hoping that I could do it with out System() 'cos System() is evil

Yes, system() is evil. However, there is no good way to call open the CHM or PDF files from your program without fiddling around with the registry (on windows, at any rate) to find what program is used to open those types of files, and then finding the location of that program so that you can run it with the appropriate API call. You have to use evil things sometimes (or do something else instead).
Last edited on
Yeah it seems to be the logical way right now. So if I use System("START help.chm") will it work or do I've to do some thing else to get it working.
You will probably need to do a bit more work to make sure you are in the right folder. For example, on Windows, get your executable path with GetModuleFileName(NULL) and then you can use the following command to open the file:
1
2
3
TCHAR filename[256];
 GetModuleFileName(NULL, filename, 256);
system("cmd /c cd /d " + std::to_string(filename) + "/docs && help.chm")

Or something like that. Play around, MSDN is your friend.
Last edited on
Will do thank you well I kinda don't have the MSDN documentation mostly used this forum and the help in here I will play around with the code you just put up.
I've been researching and found that there's a header called HtmlHelp.h can I use this in a CLI application like mine or is this for GUI based programs.
Topic archived. No new replies allowed.