Solved

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

Posted on 2002-05-22
5
249 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
  • 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need some help with listview limit text 20 113
GUI: DIalog Stacking and Popping in MS C++ 4 82
Setting nameservers after res_init fails doing res_query 2 109
Dialogbox API leak? 18 99
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
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.

828 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