Solved

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

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

739 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