Click here to Skip to main content
15,884,083 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
So for my Win32 app I use one .chm file as a manual and another .chm for representing "Version History." I use a HtmlHelpW() function for opening them.

The problem is, if I open both of them, the second .chm file hangs up, starts to consume all CPU power, and after about five seconds shows the error "Not enough memory. Try to close other applications and try again."

The question is, did anyone have this issue while working with .chm files? If so, how did you fix it?

What I have tried:

I found some info about too small stack size (1MB). I tried to increase it to 4MB and it did not change anything.

I also checked around fifteen apps and none of them seem to use multiple .chm files. The only one that can open "multiple" .chm files is AHK, but it's done by creating a new process for each CHM.

I know I can simply put everything into one CHM file, but I would like to know why I fail to open multiple CHM files.

Thanks to @CHill60 I could found the cause of the problem. Here is the code that shows everything:
C
HtmlHelpW(mainWnd, L"C:\\file1.chm", HH_DISPLAY_TOPIC, 0);   // open first file
HtmlHelpW(mainWnd, L"C:\\file2.chm", HH_DISPLAY_TOPIC, 0);   // open second file (WORKS)
HtmlHelpW(mainWnd, L"C:\\User guide.chm", HH_DISPLAY_TOPIC, 0); // open second file (DOESN'T WORK)
Posted
Updated 1-Feb-22 9:37am
v5
Comments
CHill60 1-Feb-22 10:58am    
Perhaps you could share the code you are using and what language you are coding this in
Avtem 1-Feb-22 11:04am    
The API is written in C, i use C++. Create call, i forgot that this function has more than 1 parameter... Adding the code!
Avtem 1-Feb-22 11:11am    
Okay, i just finished writing the code in empty project and it worked! Unfortunately, my app is already finished and there's about 2-3 thousand lines of code, so i am afraid the bug is somewhere else...
Avtem 1-Feb-22 11:34am    
i added the code to the original question.
i think i found out why it fails and it seems to fail because of the path. To me it looks like it fails because of spaces in the path (i am aware of % and # which don't work with .chm)

1 solution

If you want spaces in a path then you must surround the entire path with double quotation marks - see Long paths with spaces require quotation marks - Windows Server | Microsoft Docs[^]

E.g.
C++
HtmlHelpW(mainWnd, L"\"V:\\0010\\activeProjects\\Visual Studio\\PixelAt\\bin\\Win32\\Debug\\User guide.chm\"", HH_DISPLAY_TOPIC, 0);
 
Share this answer
 
v2
Comments
Avtem 1-Feb-22 11:47am    
Hm, with quotation marks:
HtmlHelpW(mainWnd, L"\"C:\\User guide.chm\"", HH_DISPLAY_TOPIC, 0);
it just does not open the file. GetLastError() returns 0 and the first file opens normally (it's not surounded with double quotes)
Avtem 1-Feb-22 12:01pm    
Anyway, i think what i will do is i copy the file to temporary path without spaces # and % and open it from that location.
i appreciate so much your help and i am happy that after such long time i know where is the problem!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900