View previous topic :: View next topic |
Author |
Message |
steveDoyle
Joined: 04 Sep 2009 Posts: 108 Location: Manchester
|
Posted: Tue Jan 26, 2016 12:00 pm Post subject: calling .CHM files from FTN95 |
|
|
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 |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Tue Jan 26, 2016 9:56 pm Post subject: |
|
|
Steve,
This is what I do:
Code: | 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. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Wed Jan 27, 2016 8:59 am Post subject: |
|
|
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. |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Wed Jan 27, 2016 10:49 am Post subject: |
|
|
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. |
|
Back to top |
|
|
steveDoyle
Joined: 04 Sep 2009 Posts: 108 Location: Manchester
|
Posted: Thu Jan 28, 2016 5:10 pm Post subject: |
|
|
Hi
HTML_HELP is just my stub function so that i can access the windows API function HtmlHelp().
HTML_HELP{ftn95} -> HtmlHelpX() {MSVS C DLL} -> HtmlHelp() {WIn API}
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 |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Fri Jan 29, 2016 7:34 pm Post subject: |
|
|
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. |
|
Back to top |
|
|
steveDoyle
Joined: 04 Sep 2009 Posts: 108 Location: Manchester
|
Posted: Fri Feb 05, 2016 12:36 pm Post subject: |
|
|
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 |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Fri Feb 05, 2016 4:53 pm Post subject: |
|
|
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 |
|
Back to top |
|
|
|