Opening a CHM file on a 64bit system

HM5 served us well, now its time has come and it has been replaced... If you have HM5 questions, please post them here.

Moderators: Alexander Halser, Tim Green

Post Reply
charles.muller
Posts: 5
Joined: Tue Sep 29, 2009 8:57 am

Opening a CHM file on a 64bit system

Unread post by charles.muller »

I'm curious to know if anyone else has come across this issue, and if so, what did they do to get around it.

I'm attempting to embed a Flash video inside a topic. It's nothing more than a standard SWF file. I'm leveraging the popular javascript library, swfobject to hook up the Flash player etc.

The project is being published to a CHM file.

I'm running Windows 7 64bit. When I open the CHM file, the Flash video fails to display. It turns out that the Microsoft HTML Help Executable program is using the 64bit version of the IE browser and not the 32bit version. Adobe have yet to release a 64bit version of Flash.

Is there a quick work around? E.g.: can I force it to use a 32bit version of hh.exe/IE? Or am I dreaming?
User avatar
Tim Green
Site Admin
Posts: 23155
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Unread post by Tim Green »

Hi Charles,

This is an interesting problem, we're going to look into it. Actually, both 64 and 32 bit versions of IE8 are installed on Windows 7 64, but the 64-bit version is the default. In normal browsing IE8 is supposed to switch to the 32-bit version automatically when it encounters a feature it can't handle otherwise, like Flash at the moment. Unfortunately, I don't think this works with CHM files. We're looking into the possibilities for this, but it may be necessary to wait until Adobe releases 64-bit Flash.
Regards,
Tim (EC Software Documentation & User Support)

Private support:
Please do not email or PM me with private support requests -- post to the forum directly.
charles.muller
Posts: 5
Joined: Tue Sep 29, 2009 8:57 am

Unread post by charles.muller »

Thanks for your timely response, Tim.

I even went as far as to investigate the Silverlight option, yet remarkably it too is not yet ready for a 64bit browser.

It appears as if I may be reduced to providing links to my video files rather than embedding them.

What's the best course of action for linking to a file from the CHM file? E.g.: if I have a folder layout like the following:

Code: Select all

helpfile.chm
/Videos
    video1.mp4
    video2.mp4
...how do I insert links to the video files? I won't know the absolute path to them it would seem.[/code]
User avatar
Tim Green
Site Admin
Posts: 23155
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Unread post by Tim Green »

Hi Charles,

Because of an uncorrected bug in the MS HTML Help viewer CHM files can only directly link to external files that are in the same folder as themselves. If you want to link to files with relative paths you need to use JavaScript to get the absolute path including the drive letter. This excellent function written by Rob Chandler has been serving people well since 2005:

Code: Select all

<script type="text/javascript">
function GetChmDir() {
  var X, Y, sl, a, ra, dir;
  ra = /::/;

  a = location.href.search(ra);
  if (a <= 0) //not a CHM - return an empty string
  return("");

  //find the index of the first colon in the string
  X = 0;
  ra = /:/;
  a = location.href.search(ra);
  if (a == 2) X = 14; //prefix = mk:@MSITStore:
  else
  if (a > 2) X = a+1; //prefix = ms-its: OR prefix = its:

  //find last back slash
  sl = "\\";
  Y = location.href.lastIndexOf(sl);
  dir = location.href.substring(X, Y);

  //UnEscape path - EG. Replace %20 with spaces - Return path with trailing \
  var dir2 = unescape(dir)
  return(dir2 + "\\");
}
</script>
To use this insert the entire block of code above including the <script> </script> tags in your HTML Page Template (Project Explorer > Configuration > HTML Page Templates > Default), directly before the closing </head> tag. You need to select the HTML source code tab for this, and don't switch back again after doing it.

Then when you want to create a link in your topic select the Script Link option in the Insert Hyperlink dialog and enter the following in the Javascript editing box:

Code: Select all

javascript:location.href=GetChmDir()+'Videos/video1.mp4'
Regards,
Tim (EC Software Documentation & User Support)

Private support:
Please do not email or PM me with private support requests -- post to the forum directly.
charles.muller
Posts: 5
Joined: Tue Sep 29, 2009 8:57 am

Unread post by charles.muller »

Thanks again Tim. I'll try your suggestion.

Re: the original issue, I did make a small discovery which I thought was worth pointing out to you. I experimented opening the CHM file from the command line.

Code: Select all

C:\Windows\SysWow64\hh.exe C:\Helpfile.chm
In the above example, the 32-bit version is loaded and the Flash video happily displays itself.

On the other hand:

Code: Select all

C:\Windows\System32\hh.exe C:\Helpfile.chm
...loads the 64-bit browser instead causing the Flash video to fail. I.e. the same behaviour as what I originally reported.

I'll admit, I'm not very knowledgeable when it comes down to Window's 64-bit implementation, but on the face of it, the Wow64 redirection method doesn't appear to be working in this instance.
I need to read up more on this, but I thought I'd share with you my discoveries so far.
User avatar
Tim Green
Site Admin
Posts: 23155
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Unread post by Tim Green »

Hi Charles,

The rather misleadingly-named SysWoW64 directory contains all the components for running 32-bit emulation mode, that is why it's working when you run it from there from the command line. The name stands for "Windows on 64-bit Windows". What is not yet clear is if there's any way to make 32-bit mode run automatically for CHM files -- at the moment I doubt if this is possible without manipulating the user's Windows Registry, which is not something you would want to do just for your help files. :?
Regards,
Tim (EC Software Documentation & User Support)

Private support:
Please do not email or PM me with private support requests -- post to the forum directly.
User avatar
Tim Green
Site Admin
Posts: 23155
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Unread post by Tim Green »

Hi Charles,

Update: I've now run quite a lot of tests on a Windows 7 64-bit system. The problem with Flash only exists if the CHM file is either run directly without explicitly specifying the 32-bit version of hh.exe, or if the CHM is run from an application that automatically calls the 64-bit version. As far as I can see most 32-bit applications making calls to CHM files will automatically get the 32-bit version. For example, when Help & Manual starts a CHM automatically after compiling it, it will use the 32-bit version and the flash videos in the CHM will display normally.

If you are programming explicitly in a 64-bit environment you apparently need to "disable the SysWoW64 redirection". I'm not a system programmer myself so I'm not 100% sure about this, but this posting on StackOverflow (see further down in the thread) contains an explanation of how to do this with links to further background information from Microsoft:

http://tinyurl.com/y88daq2

The poster emphasizes that it's important to turn redirection on again after making the call to the CHM, otherwise you may get other problems.
charles.muller
Posts: 5
Joined: Tue Sep 29, 2009 8:57 am

Unread post by charles.muller »

Thanks again Tim.

I'm now detecting the bitness of the current process to determine whether I should call the C:\Windows\SysWOW64\hh.exe directly.

Fortunately, given that our application runs natively on a 64-bit system, I haven't had to bother with the redirection disabling/re-enabling issue that you've pointed out.
Ton Epskamp
Posts: 2
Joined: Wed Feb 12, 2020 11:40 am

Re: Opening a CHM file on a 64bit system

Unread post by Ton Epskamp »

Hello Charles , Dylan and Tim,

I have been meeting this same problem after having finished developing 4 programs with 4*2(both 32 and 64 bits)*2(both debug and release)=16 executable's in Visual Studio. All of them going perfectly well with only one exception: all 64 bits executable's generate a memory violation exception as soon any help request is made. I spent a letter to Microsoft in Redmond because they before helped me solving a serious problem. As could be the case now again! So I placed my chm file in the same directory as hh.exe. But nothing changed: the same exception killing my executable. I also placed it in the HTML Help Workshop directory again in vain! Perhaps I did something wrong or I possibly misunderstood something? All my chm files also run perfectly when called from both outside my executable's and from inside my 32 bits executable's! With all regards from

Ton Epskamp.
User avatar
Alexander Halser
EC-Software Support
Posts: 4098
Joined: Mon Jun 24, 2002 7:24 pm
Location: Salzburg, Austria
Contact:

Re: Opening a CHM file on a 64bit system

Unread post by Alexander Halser »

So I placed my chm file in the same directory as hh.exe
HH.EXE is a system component. I hope you don't have it in your application folder. On the other hand, it's probably a bad idea to place your private CHM files in the c:\Windows folder.

When you open a CHM file from your application, how do you do that? You are supposed to use the Windows API call "htmlhelp()".
Alexander Halser
Senior Software Architect, EC Software GmbH
Ton Epskamp
Posts: 2
Joined: Wed Feb 12, 2020 11:40 am

Re: Opening a CHM file on a 64bit system

Unread post by Ton Epskamp »

Dear Alexander,
Indeed my only call is via htmlhelp()! So far in vain when from a 64-bit executable! I temporarily placed my chm file in the directory of hh.exe. Stronger still: I wasn't aware of hh.exe being called from htmlhelp()! Many thanks again!
Ton Epskamp.
User avatar
Tim Green
Site Admin
Posts: 23155
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Re: Opening a CHM file on a 64bit system

Unread post by Tim Green »

Hi Ton,

Your CHM files should really be in the same folder as your application. That is the normal practice. There is no need to put them in the same folder as hh.exe because that is automatically included in Windows' system path variables. Any files the CHM links to should also be in the same folder, as the entire CHM system is unable to resolve relative paths. Anything you link to from a CHM must either be in the same folder as the CHM or your link must use a full absolute path, including the drive letter.
Regards,
Tim (EC Software Documentation & User Support)

Private support:
Please do not email or PM me with private support requests -- post to the forum directly.
Post Reply