Silverfrost Forums

Welcome to our forums

calling .CHM files from FTN95

26 Jan 2016 11:00 #17162

HI everybody

My apps call .CHM files from FTN95 via a MSVS C DLL. It has work flawlessly for many year son XP/win 7 (32 & 64). It crashes when the apps are used on win8/8.1/10 (apPs work so long as help disabled)

ftn95 call CALL HTML_HELP(' ', 0, HH_INITIALIZE, IHELP_COOKIE)

C code

extern 'C' int __declspec(dllexport) HtmlHelpX(int* help_handle, char* help_topic, int* help_command, int* help_data) {

HWND help_handlex = HWND(*help_handle);
LPCSTR help_topicx = help_topic;
UINT help_commandx = (UINT)(*help_command);
DWORD help_datax = (DWORD)(*help_data);
HWND hdlx;

hdlx = HtmlHelp(help_handlex, help_topicx, help_commandx, help_datax);
return (int)hdlx;

}

The C code is too much my for my 1-dimensional fortran brain. Im assuming that is the 32 vs 64 bit issue

any pointers appreciated

TIA

steve

26 Jan 2016 8:56 #17166

Steve,

This is what I do:

      INTEGER FUNCTION IHELPSYS()
C     --------------------------
       CHARACTER*(256) PNAME
       INCLUDE <WINDOWS.INS>
      IHELPSYS = 1
      CALL GET_PROGRAM_NAME@ (PNAME)
      CALL UPCASE@ (PNAME)
      N = LEN_TRIM (PNAME)
      IF (PNAME (N-5:N) .EQ. 'SS.EXE') THEN 
      N = N - 6            ! Assumes SS.EXE
      CALL START_PPROCESS@('HH.EXE',PNAME(1:N)//'WSXHelp.chm')
      ELSE
      DO 10 I=1,N
      J = N + 1 - I
      IF (PNAME(J:J) .EQ. '') GO TO 20
  10  CONTINUE
      RETURN
  20  CALL START_PPROCESS@('HH.EXE',PNAME(1:J)//'WSXHelp.chm')
      ENDIF
      END

HH.EXE is the standard Windows program for displaying .CHM files. I have a feeling that the 'ELSE' clause covers the case that somebody changed the name of the application ... I have no doubt that this routine could be improved immensely. It is a callback function.

27 Jan 2016 7:59 #17169

I don't recognise HTML_HELP so I assume that it is a third party C function.

If you have its code then it might be possible to work out why it is failing. It looks like it is making calls into the Microsoft API function HtmlHelp. In theory you could do the same, either by making the call to HtmlHelp from FTN95 (which is tricky because it involves structures) or from a Silverfrost SCC compiled C function.

The route via HH.exe is almost certainly easier assuming that it provides all of the functionality that you need.

27 Jan 2016 9:49 #17171

What I forgot to say is that my help file is installed in the same directory as the executable, so finding the path to the executable finds it to the help file, in case the user installed the whole lot other than in the default installation directory.

It could be somewhere else, that you could find relative to the executable's location, but I've never been that sophisticated.

28 Jan 2016 4:10 #17172

Hi

HTML_HELP is just my stub function so that i can access the windows API function HtmlHelp().

HTML_HELP → HtmlHelpX() → HtmlHelp()

I think most of my confusion comes from the API definitions for LPCSTR, DWORD etc.

when i step through the code in the debugger it is the actual call to HtmlHelp() that detonates.

Thanks for at the HH.EXE route but a quick scan of the web seems to indicate that there are issues on win 8/10 but i will try it as a possible alternative.

Thanks

steve

29 Jan 2016 6:34 #17173

I used Windows 8.1 fleetingly but upgraded that and other computers to Windows 10, and haven't had a moment's trouble with HH.EXE.

It's such a mainstream part of Windows that I can't see it not working in simple cases, but I've never tried it going straight for one of the particular topics. It is easy enough to try, so I honestly recommend that you give it a whirl.

5 Feb 2016 11:36 #17176

I tried the HH.exe route with varying degrees of success. If you use start_process@() then the help file seems to become the focus so it must be closed before proceeding in the app. I tried using WINEXEC() but this create a new instance every time the help was invoked and left then open when the app was shut down.

I finally managed to get HtmlHelp() to function on win 8/8.1/10 systems so everything is now working as required. It was basically a simple typo that had no effect in xp/7 but was essential for the 64-bit systems.

if you are interest i can email you a the code

thanks for all you inputs

steve

5 Feb 2016 3:53 #17177

Steve,

You need start_Pprocess ... which starts an independent process. It's that in my demo. One P starts a process that must complete before you can go back to your app.

Eddie

Please login to reply.