NO

Author Topic: Htmlhelp does not work with Pelles C 9  (Read 2006 times)

matze

  • Guest
Htmlhelp does not work with Pelles C 9
« on: July 28, 2019, 07:52:59 PM »
Hi, I can not use Htmlhelp with Pelles C 9 successfully. If I add htmlhelp.lib to the list of library and object files, then I can successfully compile the source code. But when I start the program, the program crashes. When I debug the program, I get the error "exception: access violation" when invoking the command

HtmlHelp (NULL, NULL, HH_INITIALIZE, (DWORD) & dwCookie);

This happens only when I compile for Machine X64.
Is this just my problem?
« Last Edit: July 28, 2019, 09:12:24 PM by matze »

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: Htmlhelp does not work with Pelles C 9
« Reply #1 on: July 28, 2019, 10:27:31 PM »
First of all check to have correct library for 32 and 64bits (they are not the same), and un updated header.
Your problem is in the casting of the variable 'dwCookie'. Surely you get your code example from an ancient thread when 64bits were still to come.
The line:
Code: [Select]
HtmlHelp (NULL, NULL, HH_INITIALIZE, (DWORD) &dwCookie);
where you cast to a 32bits double word a 64bits pointer, de facto truncating the address and causing a memory access exception.
Use instead:
Code: [Select]
HtmlHelp (NULL, NULL, HH_INITIALIZE, (DWORD_PTR) &dwCookie);
This will cast the pointer to a double word that can hold all 64bits of a pointer (I know, I know another MS mess. But for sake of backward compatibility...  :()

"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

matze

  • Guest
Re: Htmlhelp does not work with Pelles C 9
« Reply #2 on: July 30, 2019, 05:23:13 PM »
Yes, that solves my problem, thanks.