Opening HTML file

Hello Friends,
I am working on win32 application and want to include a help file. I have the help file ready in word document (with a couple of figures in it) and saved it as an html file. My question is, is it some how possible to include and open the html file as a source code? I have tried the code below which i found on the net, it worked fine on my computer (where the help file is located) but when i tried to run the exe file on another computer it didn't work. I need your help.

1
2
3
4
5
6
7
8
#include <windows.h>

void main()
{ 
	LPCTSTR helpFile = "c\help\helpFile.html";
	ShellExecute(NULL, "open", helpFile, NULL, NULL, SW_SHOWNORMAL);
	system("PAUSE");
}


Thanks
Abu
Last edited on
What do you mean by "it didn't work"? What behaviour did you see? What error messages did you get?

How can we possibly help identify the problem if you don't tell us exactly what the problem is?
Thanks for your reply, what I meant was the exe file worked fine and displayed the HTML help file on the default web browser in my computer. However on another computer it dint respond and I didn't get any error message. I guess if I had put the help file in the "c\help\helpFile.html" directory on every computer, it would have worked.
Is it possible to automate this process, like to wrap everything in the exe and take it everywhere?

Last edited on
Well, I assume you don't want to simply include the entire HTML content of the help file in the C++ code. Normally, the way to do this would be to create an installer, which would bundle together the executable along with any other files it needs. You then run the installer on the machine you want to put the software on, and it will put the executable and the other files on there.

I'm not the biggest expert on Windows installers (I assume from the path you mention in your post that you're developing for Windows), but I've used the free NSIS utility before to create installers. It has its limitations, but for something simple like this it should work. You write a script using the NSIS scripting commands, and then compile it with their compiler into an executable. You can then run the executable on another Windows machine without installing NSIS on it.

I know Windows has the ability to include resources such as graphics files or string tables in an executable. I don't know if you can do this with an HTML file, but it might be possible, as an alternative to writing an installer.

I imagine the people in the Windows Programming forum here can provide more info on either of these options.
like to wrap everything in the exe and take it everywhere?
It is possible. You can use a little tool like bin2c to convert the html to source code:

http://sourceforge.net/projects/bin2c/

You need to write it to a temporary file in order to use it with ShellExecute though
I guess if I had put the help file in the "c\help\helpFile.html" directory on every computer, it would have worked.
Is it possible to automate this process, like to wrap everything in the exe and take it everywhere?


The installer would be the "best" way, even then you want to use relative paths.

Consider the folder structure:
1
2
3
4
5
6
- MyProgram
  - WebSite
    - Images
      - coolstuff.gif
    - page.html 
  - program.exe


Just as the page.html uses images found in "Images/", your program should find the website in "Website/". This will allow you to move the root folder, "MyProgram", anywhere without issues.

So this:
LPCTSTR helpFile = "c\help\helpFile.html";

Becomes:
LPCTSTR helpFile = "help\helpFile.html";

Where help is a folder that exists in the .exe directory.

Ok thanks I will try these options.
Topic archived. No new replies allowed.