The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: Eric4ever on May 30, 2006, 09:27:06 AM

Title: how to run the .chm file from the helptopic menu?
Post by: Eric4ever on May 30, 2006, 09:27:06 AM
the title says all.

i found that some methods are like this:
  .data
calculator db "C:\WINDOWS\system32\calc.exe",0

the definetion must have absolute path, and i want to run the .chm file(the same directory as the application file) from the help topic menu, how can i do it?

thanks in advance.
Title: Re: how to run the .chm file from the helptopic menu?
Post by: stanhebben on May 30, 2006, 09:32:16 AM
http://en.wikibooks.org/wiki/Windows_Programming/Compiled_HTML_Help seems to explain how to open html help files.

Stan
Title: Re: how to run the .chm file from the helptopic menu?
Post by: Eric4ever on May 30, 2006, 10:44:03 AM
Thanks Stan :U

Title: Re: how to run the .chm file from the helptopic menu?
Post by: Eric4ever on May 31, 2006, 06:00:48 AM
there is still a question.

how to convert the htmlhelp.h to htmlhelp.inc?
i tried the 'h2inc' application, but it errors at line 170...
Title: Re: how to run the .chm file from the helptopic menu?
Post by: stanhebben on May 31, 2006, 08:48:16 AM
I see there's a htmlhelp.inc file in the masm include files, but that one seems a bit limited.

Sec, I'll translate it manually. (only 400 lines  :wink)

Stan
Title: Re: how to run the .chm file from the helptopic menu?
Post by: stanhebben on May 31, 2006, 09:12:27 AM
Ok, here it is. Enjoy!

And correct my errors, if any.

Stan

[attachment deleted by admin]
Title: Re: how to run the .chm file from the helptopic menu?
Post by: Eric4ever on June 01, 2006, 01:47:01 AM
hi stan,

thanks your kindly help. but what's the problem?

htmlhelp.lib(init.obj) : error LNK2001: unresolved external symbol __imp__RegCloseKey@4
htmlhelp.lib(init.obj) : error LNK2001: unresolved external symbol __imp__RegQueryValueExA@24
htmlhelp.lib(init.obj) : error LNK2001: unresolved external symbol __imp__RegOpenKeyExA@20
firmware.exe : fatal error LNK1120: 3 unresolved externals
NMAKE : fatal error U1077: 'C:\WINDOWS\system32\cmd.exe' : return code '0x460'
Stop.


Title: Re: how to run the .chm file from the helptopic menu?
Post by: GregL on June 01, 2006, 03:04:17 AM
INCLUDELIB Advapi32.lib
Title: Re: how to run the .chm file from the helptopic menu?
Post by: Eric4ever on June 02, 2006, 05:15:00 AM
thanks Greg, it's ok, but there is still a question: how can i link to the help file in the current directory?

I define the help file liake this:

szHelpFile    db    "D:\Project\program\help.chm",0


the help menu can only be valid when the help file exists at the D:\Project\program directory. when I move the folder which contains the application and help file, the help menu is invalid. so, how can i make it move-and-run? i try to define is as:
szHelpFile    db    ".\help.chm",0

but it error..
Title: Re: how to run the .chm file from the helptopic menu?
Post by: stanhebben on June 02, 2006, 08:48:02 AM
Must be ..\help.chm I think.
Title: Re: how to run the .chm file from the helptopic menu?
Post by: Ian_B on June 02, 2006, 09:58:27 AM
Quote from: Eric4ever on June 02, 2006, 05:15:00 AM
thanks Greg, it's ok, but there is still a question: how can i link to the help file in the current directory?
If the help file should always be in the same folder as the running app, use:
invoke GetCurrentDirectory, (returnbufferlength), (returnbufferpointer)
Then you'll have to concatenate your "\help.chm" onto the end of whatever's returned. Make sure you check whether there's already a "\" on the end of that, I'm not sure whether the path returning API routines add it.

Ian_B
Title: Re: how to run the .chm file from the helptopic menu?
Post by: Shantanu Gadgil on June 02, 2006, 10:25:54 AM
Would using GetModuleFileName be a better idea? I always use that to evaluate the .ini location of my app.
Title: Re: how to run the .chm file from the helptopic menu?
Post by: Mark Jones on June 02, 2006, 07:42:38 PM
Shantanu is correct, GetCurrentDirectory does not necessarily return the directory the calling app is running from, whereas GetModuleFileName does. I found that out the hard way. :wink
Title: Re: how to run the .chm file from the helptopic menu?
Post by: Eric4ever on June 15, 2006, 02:08:52 AM
local    @szBuffer[128]:byte

invoke    GetModuleFileName,NULL,addr @szFileName,MAX_PATH
......


the GetModuleFileName retrieves the full path and filename, what should I do the in the next step in order to prepare for the invoke of htmlhelp?

thanks in advance.
Title: Re: how to run the .chm file from the helptopic menu?
Post by: zooba on June 15, 2006, 03:11:02 AM
Include SHLWAPI include and library and use PathRemoveFileSpec(szPath) and PathCombine(szBuffer, szPath, szFile).

Cheers,

Zooba :U
Title: Re: how to run the .chm file from the helptopic menu?
Post by: Eric4ever on June 15, 2006, 03:26:58 AM
i'm sorry, zooba, i cannot catch it.

Could you give me some examples to learn?
Title: Re: how to run the .chm file from the helptopic menu?
Post by: Ian_B on June 15, 2006, 12:32:29 PM
Or just run through the string byte-by-byte looking for either the null-byte end of string or a second "\" after the first "\" character in the drivespec ("C:\"), which is probably all the SHLWAPI stuff does anyway, and will save you a slow external API call and an include. Then simply truncate the string by adding a null-byte after the "\" if you found one, or a "\" and a null-byte if you didn't.

EDIT: forgot you are definitely getting a full file name after the path with this function. You just need code like this, definitely too minimal to waste calling SHLWAPI functions for:

        lea     ebx, TestPathSpec       ; a buffer MAX_PATH chars in length
        invoke  GetModuleFileName, NULL, ebx, MAX_PATH
        lea     ecx, [ebx+2]            ; first check pos is slash at end of C:\
        test    eax, eax
        jz      FatalPathError
@@:
        mov     al, [ecx]
        add     ecx, 1
        test    al, al                  ; is it the string end
        jz      @F
        cmp     al, "\"                 ; is it a path delimiter
        jne     @B
        mov     edx, ecx                ; save last path delimiter found
        jmp     @B
@@:
        mov     [edx], al               ; null-terminate path
        sub     edx, ebx                ; get path length including last delimiter


Ian_B