Solved

Can Anybody Know what is the problem with this code (using HTMLHelp API function)?

Posted on 2002-05-22
5
253 Views
Last Modified: 2012-08-13
When I run the code bellow I have got a system crashes, can anybody tell me what is the problem?

-----------------------------------------------
void OnHelp()
{
     HINSTANCE inst = LoadLibrary("HHCTRL.OCX");
     (FARPROC&) htmlHelp = GetProcAddress(inst,
                                      "HtmlHelp");
     HWND g = htmlHelp(m_hWnd,                          "C:\\MyHelp.chm",                          2, NULL);
     FreeLibrary(inst);

}
------------------------------------
I suspect that the problem is from the third parameter!!

Pls Help!!!
0
Comment
Question by:AHD
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 7028098
The problem is that you do not check whether 'LoadLibrary()' suceeds and 'GetProcAddress()' returns a valid pointer:

void OnHelp()
{
    HINSTANCE inst = LoadLibrary("HHCTRL.OCX");

    if ( NULL == inst) {

    // error
    }
   
    FARPROC htmlHelp = GetProcAddress(inst,
                                     "HtmlHelp");

    if ( NULL == htmlHelp) {

    // error
    }

    HWND g = htmlHelp(m_hWnd,                          "C:\\MyHelp.chm",                          2,
NULL);
    FreeLibrary(inst);

}
0
 

Author Comment

by:AHD
ID: 7028116
No, I have debug the code and the Loadlibrary function executed successfuly, the problem found in htmlHelp function itself, specialy the third parameter I have passed value 2 without knowing what is the exactly value?
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7028408
In the file HTMLHELP.H, you will see:

#define HH_DISPLAY_INDEX        0x0002  // not currently implemented

so you ar passing in a request for an 'unimplemented command'.  However, another reference indicates that this is an avaialbel command.  If used, you need to pass in a keyword to lookup

Typcial usage is to use (e.g.):

#include <htmlhelp.h>

HWND g = htmlHelp(
        m_hWnd,
        "C:\\MyHelp.chm",
        HH_DISPLAY_TOPIC, // 0
        NULL
);

To lookup a keyword, try:

HWND g = htmlHelp(
        m_hWnd,
        "C:\\MyHelp.chm",
        HH_DISPLAY_INDEX,  // 2
        (DWORD)"Frabisculate"
);


There is extensive on-line infoemation on how to use the HtmlHelp API here:

http://search.microsoft.com/gomsuri.asp?n=1&c=rp_Results&siteid=us/dev&target=http://msdn.microsoft.com/library/en-us/htmlhelp/html/vsconHH1Start.asp

-- Dan
0
 

Author Comment

by:AHD
ID: 7034471
Unfortunitly my machine can not find <htmlhelp.h> file,where can I find this file

0
 
LVL 49

Accepted Solution

by:
DanRollins earned 50 total points
ID: 7037857
It comes as part of the HtmlHelp Workshop:

http://www.microsoft.com/downloads/release.asp?releaseid=33071

It's hard to imagine even starting to work on an HtmlHelp system without having this.

-- Dan
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question