Solved

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

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

762 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now