BUG: A Fatal Error Occurs If You Run a Microsoft Visual Basic Application by Using the HtmlHelp API (244140)



The information in this article applies to:

  • Microsoft Visual Basic Learning Edition for Windows 5.0
  • Microsoft Visual Basic Learning Edition for Windows 6.0
  • Microsoft Visual Basic Professional Edition for Windows 5.0
  • Microsoft Visual Basic Professional Edition for Windows 6.0
  • Microsoft Visual Basic Enterprise Edition for Windows 5.0
  • Microsoft Visual Basic Enterprise Edition for Windows 6.0

This article was previously published under Q244140

SYMPTOMS

A Microsoft Visual Basic application that is running in the IDE uses the HtmlHelp function to display a Help window. If you close the calling form or you stop the project, a fatal error occurs. If you use Microsoft Windows 95 or Microsoft Windows 98, the Visual Basic design environment shuts down with no message. If you use Microsoft Windows NT, an access violation occurs. Depending on the operating system that you are using, an invalid page fault (IPF) or an access violation occurs in a compiled program.

RESOLUTION

By default, the HTML Help ActiveX control (Hhctrl.ocx) runs in a second thread. To work around this issue, you must force Hhctrl.ocx to run in a single thread in Visual Basic. You can do this by calling HtmlHelp with the HH_INITIALIZE command when Visual Basic loads, and by calling HtmlHelp with the HH_UNINITIALIZE command when Visual Basic unloads. To run these commands when Visual Basic starts, create an add-in that automatically loads when you start the IDE.

To use this add-in, register HHCTRLAV.dll by using regsvr32. To do this, follow these steps:
  1. Click Start, and then click Run.
  2. Type regsvr32 c:\HHCtrlAV\HHCtrlAV.dll.
  3. Press ENTER.

    A message informs you that DLLRegisterServer succeeded.
You must also set up the add-in to be recognized by Visual Basic, and to be loaded when Visual Basic starts. To do this, add HHCTRLAV.Connect=1 to the end of the Vbaddin.ini file. The Vbaddin.ini file is located in C:\Windows or in C:\WinNT.

You can now start Visual Basic. HHCtrlAV is in the list of loaded add-ins. If HHCtrlAV is started when Visual Basic starts (the Load on Startup option is enabled), then you do not receive the access violation in VB5.EXE or VB6.EXE as a result of Hhctrl.ocx.

The source code for this add-in is also included. With this source code, you can modify the add-in. The following file is available for download from the Microsoft Download Center:
HHCtrlAV_AddIn.EXE

http://download.microsoft.com/download/3/1/d/31d348d4-10b3-49e2-ad70-acdff964eeb4/HHCtrlAV_AddIn.exe

For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:

119591 How to Obtain Microsoft Support Files from Online Services

Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce the Behavior


To reproduce the behavior on Microsoft Windows 2000 and Microsoft Windows XP, follow these steps:
  1. Start a new Visual Basic Standard EXE project. By default, Form1 is created.
  2. Add a CommandButton to Form1.
  3. Add the following code to the General Declarations section of Form1:
        Option Explicit
        
        Private Declare Function HtmlHelp Lib "hhctrl.ocx" _
                Alias "HtmlHelpA" _
                (ByVal hwndCaller As Long, _
                ByVal pszFile As String, _
                ByVal uCommand As Long, _
                ByVal dwData As Long) _
                As Long
        
        Private Const HH_CLOSE_ALL = &H12
        
        Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
            HtmlHelp hWnd, "", HH_CLOSE_ALL, 0&
        End Sub
    					
  4. Run the project, and then close Form1 when it appears. This reproduces the problem approximately one out of three times.
To reproduce this behavior on Microsoft Windows 95, Microsoft Windows 98, or Microsoft Windows NT 4.0, follow these steps:
  1. Start a new Visual Basic Standard EXE project. By default, Form1 is created.
  2. Add a CommandButton to Form1.
  3. Add the following code to the General Declarations section of Form1:
       Option Explicit
    
       Private Declare Function HtmlHelp Lib "hhctrl.ocx" _
               Alias "HtmlHelpA" _
               (ByVal hwndCaller As Long, _
               ByVal pszFile As String, _
               ByVal uCommand As Long, _
               ByVal dwData As Long) _
               As Long
    
       Private Const HH_DISPLAY_TOPIC = &H0
    
       Private Sub Command1_Click()
          Call HtmlHelp(Me.hWnd, "IEXPLORE.CHM", _
                              HH_DISPLAY_TOPIC, 0)
       End Sub
    					
  4. Run the project. Click Command1, and then close the form. Do not close the HTML Help window that appears.

REFERENCES


For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

194116 INFO: HTML Help Embedded Windows - Issues and Workarounds


Modification Type:MinorLast Reviewed:8/5/2004
Keywords:kbdownload kbBug kbIDEProject kbpending KB244140 kbAudDeveloper