Delphi program uses a point of modification of CHM help

xiaoxiao2021-03-06  84

??????? Delphi does not provide the functionality that directly controls the HM format, but thanks to Robert Chandler to help us convert HTMLHELP.H to Object Pascal format.

??????? But in the process of use, there are some problems, mainly on 2000, XP, and 2003, if the client does not register hhctrl.ocx, there will be access memory errors, and the help file will also Can't open.

??????? In fact, Open HH.PAS, it is easy to find a solution.

??????? In HH.PAS, it works through 3 function pointers, and the function pointer is taken in Modulehhctrl, let's take a look at Modulehhctrl's Way:

Procedure modulehhhctrl;

VAR

OCXFN: String;

Begin

Ocxfn: = getPathtohhctrlocx;

If FileExists (OCXFN) THEN

Begin

HHCTRLHANDLE: = loadingLibrary (Pchar (OCXFN))

IF hhctrlhandle <> 0 THEN

Begin

@HTMLHELPA: = GetProcaddress (hhctrlhandle, 'htmlhelpa');

@HTMLHELPW: = GetProcaddress (hhctrlhandle, 'htmlhelpw');

@HTMLHELP: = GetProcaddress (hhctrlhandle, 'htmlhelpa');

end

END;

END;

This can be seen when the OCXFN does not exist (OCXFN's registration information in the registry in the registry --- Please look at getPathtohhctrlocx, or when LoadLibrary fails!

Ok, then we will change it here. When you get it in the registry, you will directly loadLibrary, after all, hhctrl.ocx exists under the% system%.

But if you really can't get it??? We still want to open help files ... Think, shellexceute, right ... Let the system open.

Therefore, the result of the final revision is as follows:

// MODI BY LIHD 20040823 Modified in the case where Hhctrl.ocx is not registered, when the registry information is not found, first directly LOAD, no longer on Shellexecute

Unit HH;

{

============================================================================================================================================================================================================= =============

Translated from htmlhelp.h by Robert Chandler

Copyright (c) 1999 The Helpware Group

Email: Robertc@helpware.net

Web: http://www.helpware.net

Platform: Delphi 3 / Delphi 4

NOTES:

Htmlhelp.h is distributed with hh workshop

Changes:

18-Feb-1999 ORGINAL VERSION (HH 1.2) 04-APR-1999 Now Uses Loadlibrary to Silently Detect and Load Hhcrtl.ocx

============================================================================================================================================================================================================= =============

}

Interface

Uses Windows, sysutils, registry, shellapi;

{Externals from hhctrl.ocx}

VAR

Hhctrlhandle: thandle = 0; // 0 if hhctrl.ocx could not be loading

Const

hhctrllib = 'hhctrl.ocx';

Var // Function Are Invalid if hhctrlhandle = 0

HTMLHELPA: Function (hwndcaller: hwnd; pszfile: pchar; ucommand: cardinal; dwdata: dword): hWnd; stdcall;

HTMLHELPW: Function (hwndcaller: hwnd; pszfile: pchar; ucommand: cardinal; dwdata: dword): hwnd; stdcall;

HTMLHELP: Function (hwndcaller: hwnd; pszfile: pchar; ucommand: cardinal; dwdata: dword): hwnd; stdcall;

{other exports}

Function getPathtohhctrlocx: String;

{Use the folload for getprocaddress to load from hhctrl.ocx}

Const

Atom_htmlhelp_api_ansi = 14;

Atom_htmlhelp_api_unicode = 15;

{Commands to pass to htmlhelp ()}

Const

HH_DISPLAY_TOPIC = $ 0000; {**}

Hh_help_finder = 0000; // WinHelp Equivalent

Hh_display_toc = $ 0001; // NOT CURRENTLY IMPLEMENTED

HH_DISPLAY_INDEX = $ 0002; // NOT CURRENTLY IMPLEMENTED

Hh_display_search = $ 0003; // NOT CURRENTLY IMPLEMENTED

Hh_set_win_type = $ 0004;

HH_GET_WIN_TYPE = $ 0005;

HH_GET_WIN_HANDLE = $ 0006;

HH_ENUM_INFO_TYPE = $ 0007; // Get Info Type Name, Call Repeatedly to Enumerate, -1 At Endh_set_info_type = $ 0008; // add info type to filter.

Hh_sync = $ 0009;

HH_RESERVED1 = $ 000A;

HH_RESERVED2 = $ 000B;

HH_RESERVED3 = $ 000c;

HH_keyword_lookup = 000d;

HH_DISPLAY_TEXT_POPUP = $ 000E; // Display String Resource ID OR TEXT IN A POPUP Window

HH_HELP_CONTEXT = $ 000f; {**} // Display mapped numeric value in dwdata

HH_TP_HELP_CONTEXTMENU = $ 0010; // Text Popup Help, Same As WinHelp Help_ContextMenu

HH_TP_HELP_WM_HELP = $ 0011; // text popup help, Same as WinHelp Help_WM_HELP

Hh_close_all = 0012; // Close All Windows Opened Directly or Indirectly by The Caller

HH_ALINK_LOOKUP = $ 0013; // alink version of hh_keyword_lookup

HH_GET_LAST_ERROR = $ 0014; // not currently imported // see hherror.h

HH_ENUM_CATEGORY = $ 0015; // get category name, call repeatedly to enumerate, -1 at end

HH_ENUM_CATEGORY_IT = $ 0016; // Get Category Info Type Sermbers, Call Repeatedly To Enumerate, -1 At end

HH_RESET_IT_FILTER = $ 0017; // Clear The INFO TYPE FILTER OF All Info Types.

HH_SET_INCLUSIVE_FILTER = $ 0018; // set inclusive filtering method for untyped Topics to be included in display

HH_SET_EXCLUSIVE_FILTER = $ 0019; // SET Exclusive Filtering Method for untyped Topics to Be Excluded from Display

HH_Initialize = 001c; // Initializes The Help System.

HH_UNINIALIZE = $ 001d; // uninitializes the help system.

HH_PRETRANSLATEMESSAGE = $ 00FD; // pumps messages (NULL, NULL, MSG *).

HH_SET_GLOBAL_PROPERTY = $ 00FC; // set a global protection. (Null, null, hh_gprop) {window profment}

Const

HHWIN_PROP_TAB_AUTOHOHODESHOW = DWORD ($ 00000001); // (1 << 0) Automatically Hide / Show Tri-Pane WINDOW

HHWIN_PROP_ONTOP = DWORD ($ 00000002); // (1 << 1) TOP-MOST WINDOW

HHWIN_PROP_NOTITLEBAR = DWORD ($ 00000004); // (1 << 2) No Title Bar

HHWIN_PROP_NODEF_STYLES = DWORD ($ 00000008); // (1 << 3) No Default Window Styles (ONLY HH_WINTYPE.DWSTYLES)

HHWIN_PROP_NODEF_EXSTYLES = DWORD ($ 00000010); // (1 << 4) No Default Extended Window Styles (ONLY HH_WINTYPE.DWEXSTYLES)

HHWIN_PROP_TRI_PANE = DWORD ($ 00000020); // (1 << 5) Use a tri-pane window

HHWIN_PROP_NOTB_TEXT = DWORD ($ 00000040); // (1 << 6) No Text On Toolbar Buttons

HHWIN_PROP_POST_QUIT = DWORD ($ 00000080); // (1 << 7) Post WM_Quit Message When Window Closes

HHWIN_PROP_AUTO_SYNC = DWORD ($ 00000100); // (1 << 8) Automatical Ssync Contents and Index

HHWIN_PROP_TRACKING = DWORD ($ 00000200); // (1 << 9) Send Tracking Notification Messages

HHWIN_PROP_TAB_SEARCH = DWORD ($ 00000400); // (1 << 10) include Search Tab in Navigation Pane

HHWIN_PROP_TAB_HISTORY = DWORD ($ 00000800); // (1 << 11) Include History Tab in Navigation Pane

HHWIN_PROP_TAB_FAVORITES = DWORD ($ 00001000); // (1 << 12) include Favorites Tab in Navigation Pane

HHWIN_PROP_CHANGE_TITLE = DWORD ($ 00002000); // (1 << 13) Put Current HTML Title In Title Bar

HHWIN_PROP_NAV_ONLY_WIN = DWORD ($ 00004000); // (1 << 14) ONLY DISPLAY THE NAVIGATION WINDOW

HHWIN_PROP_NO_TOOLBAR = DWORD ($ 00008000); // (1 << 15) DON't Display A Toolbarhhwin_Prop_Menu = DWORD ($ 00010000); // (1 << 16) Menu

HHWIN_PROP_TAB_ADVSEARCH = DWORD ($ 00020000); // (1 << 17) Advanced FTS UI.

HHWIN_PROP_USER_POS = DWORD ($ 00040000); // (1 << 18) After Initial Creation, User Controls Window Size / Position

HHWIN_PROP_TAB_CUSTOM1 = DWORD ($ 00080000); // (1 << 19) UsesE Custom Tab # 1

HHWIN_PROP_TAB_CUSTOM2 = DWORD ($ 00100000); // (1 << 20) Uses Custom Tab # 2

HHWIN_PROP_TAB_CUSTOM3 = DWORD ($ 00200000); // (1 << 21) UsesE Custom Tab # 3

HHWIN_PROP_TAB_CUSTOM4 = DWORD ($ 00400000); // (1 << 22) Use Custom Tab # 4

HHWIN_PROP_TAB_CUSTOM5 = DWORD ($ 00800000); // (1 << 23) Use Custom Tab # 5

HHWIN_PROP_TAB_CUSTOM6 = DWORD ($ 01000000); // (1 << 24) Use Custom Tab # 6

HHWIN_PROP_TAB_CUSTOM7 = DWORD ($ 02000000); // (1 << 25) Uses Custom Tab # 7

HHWIN_PROP_TAB_CUSTOM8 = DWORD ($ 04000000); // (1 << 26) Use Custom Tab # 8

HHWIN_PROP_TAB_CUSTOM9 = DWORD ($ 08000000); // (1 << 27) Use Custom Tab # 9

HHWIN_TB_MARGIN = DWORD ($ 10000000); // (1 << 28) The Window Type Has A Margin

{window parameters}

Const

HHWIN_PARAM_PROPERTIES = DWORD ($ 00000002); // (1 << 1) Valid FswinProperties

HHWIN_PARAM_STYLES = DWORD ($ 00000004); // (1 << 2) Valid DWStyles

HHWIN_PARAM_EXSTYLES = DWORD ($ 00000008); // (1 << 3) Valid DwexStyles

HHWIN_PARAM_RECT = DWORD ($ 00000010); // (1 << 4) Valid RcWindowPOS

HHWIN_PARAM_NAV_WIDTH = DWORD ($ 00000020); // (1 << 5) Valid INAVWIDTHHWIN_PARAM_SHOWSTATE = DWORD ($ 00000040); // (1 << 6) Valid nShowState

HHWIN_PARAM_INFOTYPES = DWORD ($ 00000080); // (1 << 7) Valid Apinfotypes

HHWIN_PARAM_TB_FLAGS = DWORD ($ 00000100); // (1 << 8) Valid Fstoolbarflags

HHWIN_PARAM_EXPANSION = DWORD ($ 00000200); // (1 << 9) Valid Fnotexpanded

HHWIN_PARAM_TABPOS = DWORD ($ 00000400); // (1 << 10) Valid TabPOS

HHWIN_PARAM_TABORDER = DWORD ($ 00000800); // (1 << 11) Valid Taborder

HHWIN_PARAM_HISTORY_COUNT = DWORD ($ 00001000); // (1 << 12) Valid Chistory

HHWIN_PARAM_CUR_TAB = DWORD ($ 00002000); // (1 << 13) Valid CurnavType

{Button Constants}

Const

HHWIN_BUTTON_EXPAND = DWORD ($ 00000002); // (1 << 1) Expand / Contract Button

HHWIN_BATTON_BACK = DWORD ($ 00000004); // (1 << 2) Back Button

HHWIN_BUTTON_FORWARD = DWORD ($ 00000008); // (1 << 3) Forward Button

HHWIN_BUTTON_STOP = DWORD ($ 00000010); // (1 << 4) Stop Button

HHWIN_BUTTON_REFRESH = DWORD ($ 00000020); // (1 << 5) Refresh Button

HHWIN_BUTTON_HOME = DWORD ($ 00000040); // (1 << 6) Home Button

HHWIN_BUTTON_BROWSE_FWD = DWORD ($ 00000080); // (1 << 7) Not Implement

HHWIN_BUTTON_BROWSE_BCK = DWORD ($ 00000100); // (1 << 8) Not IMplement

HHWIN_BUTTON_NOTES = DWORD ($ 00000200); // (1 << 9) Not IMplement

HHWIN_BUTTON_CONTENTS = DWORD ($ 00000400); // (1 << 10) Not IMplement

HHWIN_BUTTON_SYNC = DWORD ($ 00000800); // (1 << 11) Sync Buttonhhwin_Button_Options = DWORD ($ 00001000); // (1 << 12) Options Button

HHWIN_BUTTON_PRINT = DWORD ($ 00002000); // (1 << 13) Print Button

HHWIN_BUTTON_INDEX = DWORD ($ 00004000); // (1 << 14) Not IMplement

HHWIN_BUTTON_SEARCH = DWORD ($ 00008000); // (1 << 15) Not IMplement

HHWIN_BUTTON_HISTORY = DWORD ($ 00010000); // (1 << 16) Not IMPLEMENTED

HHWIN_BUTTON_FAVORITES = DWORD ($ 00020000); // (1 << 17) Not IMplement

HHWIN_BUTTON_JUMP1 = DWORD ($ 00040000); // (1 << 18)

HHWIN_BUTTON_JUMP2 = DWORD ($ 00080000); // (1 << 19)

HHWIN_BUTTON_ZOOM = DWORD ($ 00100000); // (1 << 20)

HHWIN_BUTTON_TOC_NEXT = DWORD ($ 00200000); // (1 << 21)

HHWIN_BUTTON_TOC_PREV = DWORD ($ 00400000); // (1 << 22)

HHWIN_DEF_BUTTONS = (hhwin_button_expand

OR hhwin_button_back

OR hhwin_button_options

Or hhwin_button_print);

{Button IDS}

Const

IDTB_EXPAND = 200;

IDTB_CONTRACT = 201;

IDTB_STOP = 202;

IDTB_REFRESH = 203;

IDTB_BACK = 204;

IDTB_HOME = 205;

IDTB_SYNC = 206;

IDTB_PRINT = 207;

IDTB_OPTIONS = 208;

IDTB_FORWARD = 209;

IDTB_NOTES = 210; // Not Implement

IDTB_BROWSE_FWD = 211;

IDTB_BROWSE_BACK = 212;

IDTB_CONTENTS = 213; // Not Implement

IDTB_INDEX = 214; // Not Implement

IDTB_SEARCH = 215; // not implementidtb_history = 216; // not imported

IDTB_FAVORITES = 217; // Not Implement

IDTB_JUMP1 = 218;

IDTB_JUMP2 = 219;

IDTB_CUSTOMIZE = 221;

IDTB_ZOOM = 222;

IDTB_TOC_NEXT = 223;

IDTB_TOC_PREV = 224;

{NOTIFICATION CODES}

Const

HHN_FIRST = (0-860);

HHN_LAST = (0-879);

HHN_NAVCOMPLETE = (HHN_FIRST-0);

HHN_TRACK = (HHN_FIRST-1);

HHN_WINDOW_CREATE = (HHN_FIRST-2);

Type

HHN_NOTIFY = Packed Record // TAGHHN_NOTIFY

HDR: TNMHDR;

Pszurl: pwidechar; // pcstr: multi-byte, null-terminated string

END;

HH_POPUP = Packed Record // TAGHH_POPUP

CBSTRUCT: INTEGER; // Sizeof this Structure

Hinst: Hinst; // Instance Handle for String Resource

IDString: cardinal; // String Resource ID, or text id if pszfile is specified in Htmlhelp Call

PSZText: pchar; // used if idstring is Zero

PT: tpoint; // Top Center of Popup Window

CLRFOREGROUND: colorref; // use -1 for default

CLRBACKGROUND: colorRef; // use -1 for default

RcMargins: TRECT; // Amount of Space Between Edges of window and text, -1 for Each Member to ignore

PSZFONT: PCHAR; // Facename, Point Size, Char Set, Bold Italic Underline

END;

Hh_aklink = packed record // taghh_aklink

CBSTRUCT: INTEGER; // Sizeof this Structure

FRESERVED: BOOL; // Must Be false (really!)

PszkeyWords: pchar; // semi-colon Separated Keywords

Pszurl: pchar; // url to jump to if no keywords found (may be null) pszmsgtext: pchar; // message text to display in MessageBox if pszurl is null and no keyword match

Pszmsgtitle: Pchar; // Message Text to Display In Messagebox if Pszurl Is Null and no keyword match

Pszwindow: pchar; // window to display url in

FINDEXONFAIL: BOOL; // Displays Index if Keyword Lookup Fails.

END;

Type

Phhwin_navtype = ^ twhwin_navtype;

ThHWIN_NAVTYPE = INTEGER;

Const

HHWIN_NAVTYPE_TOC = 0;

HHWIN_NAVTYPE_INDEX = 1;

HHWIN_NAVTYPE_SEARCH = 2;

HHWIN_NAVTYPE_FAVORITES = 3;

HHWIN_NAVTYPE_HISTORY = 4; // Not Implement

HHWIN_NAVTYPE_AUTHOR = 5;

HHWIN_NAVTYPE_CUSTOM_FIRST = 11;

Type

HH_ITYPE =

IT_INCLUSIVE,

IT_EXCLUSIVE,

IT_HIDDEN);

TAGHH_ENUM_IT = PACKED RECORD / / TAGHH_ENUM_IT, HH_ENUM_IT, * PhH_ENUM_IT

CBSTRUCT: Integer; // Size of this Structure

ITYPE: INTEGER; // The Type of the Information Type IE. Inclusive, Exclusive, or Hidden

Pszcatname: pansichar; // set to the name of the category to enumerate; Else Null

Pszitname: Pansichar; // Volitile Pointer to the name of the infintpe. allocated by call. Caller resposssible for Freeing

Pszitdescription: Pansichar; // Volitile Pointer to the description of the infint.

END;

ThhenumInfotype = taghh_enum_it;

PhhenumInfotype = ^ thhenumInfotype;

Type

TAGHH_ENUM_CAT = Packed Record // TAGHH_ENUM_CAT, HH_ENUM_CAT, * PhH_ENUM_CAT

CBSTRUCT: Integer; // Size of this Structure

Pszcatname: PanscatName: Pansichar; // Volitile Pointer to the category namepszcatdescription: Pansichar; // Volitile Pointer to Category Description

END;

Thhenumcat = taghh_enum_cat;

Phhenumcat = ^ thhenumcat;

Type

TAGHH_SET_INFOTYPE = Packed RECORD // TAGHH_SET_INFOTYPE, HH_SET_INFOTYPE, * Phh_set_infotype

CBSTRUCT: Integer; // the size of this structure

.. // the name of the category, if any, the infintpe is a member of.

Pszinfotypename: Pansichar; // the name of the info type to add to the filter

END;

ThHSetInfotype = tagh_set_infotype;

Phhsetinfotype = ^ thrhsetinfotype;

Type

HH_INFOTYPE = DWORD;

Thhinfotype = HH_INFOTYPE;

Phhinfotype = ^ thhinfotype; // phh_infotype

Type

ThHWINNAVTABS =

HHWIN_NAVTAB_TOP,

HHWIN_NAVTAB_LEFT,

HHWIN_NAVTAB_BOTTOM

);

Const

HH_max_tabs = 19; // maximum number of tabs

Const

HH_TAB_CONTENTS = 0;

HH_TAB_INDEX = 1;

HH_TAB_SEARCH = 2;

HH_TAB_FAVORITES = 3;

HH_TAB_HISTORY = 4;

HH_TAB_AUTHOR = 5;

HH_TAB_CUSTOM_FIRST = 11;

HH_TAB_CUSTOM_LAST = HH_MAX_TABS;

HH_MAX_TABS_CUSTOM = (hh_tab_custom_last - hh_tab_custom_first 1);

{HH_DISPLAY_SEARCH Command Related Structures and constants}

Const

HH_FTS_DEFAULT_PROXIMITY = (-1);

Type

TAGHH_FTS_QUERY = PACKED RECORD // TAGHH_FTS_QUERY, HH_FTS_QUERY

CBSTRUCT: Integer; // sizeof structure in bytes.

FunicodeStrings: Bool; // True IF All strings are unicode.

PSZSearchQuery: pchar; // string containing the search query.

iProxImity: longint; // Word proximity.fstemmedsearch: Bool; // True for StemmedSearch ONLY.

FtitleOnly: Bool; // True for Title Search Only.

FEXECUTE: BOOL; / / TRUE TO INITIATE The Search.

Pszwindow: pchar; // window to display in

END;

HH_FTS_QUERY = tagh_fts_query;

{Hh_wintype structure}

Type

TAGHH_WINTYPE = Packed Record // TAGHH_WINTYPE, HH_WINTYPE, * PhH_WINTYPE

CBSTRUCT: Integer; // in: Size of this Structure Including all information type Types. INCLUDING All INFORMATION TYPES

Funicodestrings: Bool; // In / Out: True IF All Strings Are IN Unicode

PSZTYPE: PCHAR; // IN / OUT: NAME OF A TYPE OF WINDOW

fsvalidmembers: dword; // in: bit flag of valid members (hhwin_param_)

FswinProperties: dword; // in / out: Properties / Attributes of the window (hhwin_)

PSZCAPTION: PCHAR; // In / Out: Window Title

DWStyles: dWord; // in / out: window styles

DWEXSTYLES: DWORD; // IN / OUT: Extended Window Styles

RcWindowPos: TRECT; // IN: Starting Position, Out: Current position

NSHOWSTATE: Inteder; // in: Show State (E.g., sw_show)

HWndHelp: hwnd; // out: Window Handle

HWndCaller: hwnd; // out: WHO Called this window

Painfotypes: phhinfotype; // in: Pointer to an Array of Information Types

{THE FOLLOWING MEMBERS Are ONLY VALID IF HHWIN_PROP_TRI_PANE IS Set}

HWNDTOOLBAR: HWND; // Out: Toolbar Window In Tri-Pane WINDOW

HWndNavigation: hwnd; // out: navigation window in tri-pane window

HWNDHTML: HWND; // Out: Window Displaying HTML in Tri-Pane WINDOW

INAVWIDTH: INTEGER; // IN / OUT: Width of navigation windowrchtml: TRECT; / / OUT: HTML Window Coordinates

PSZTOC: PCHAR; // in: location of the table of contents file

Pszindex: pchar; // in: location of the index file

Pszfile: pchar; // in: Default location of the html file

Pszhome: Pchar; // In / Out: html file to display des copy

FSTOOLBARFLAGS: DWORD; // in: Flags Controling The Appearance of the Toolbar

FNOTEXPANDED: BOOL; // in: True / false to Contract or Expand, Out: Current State

CurnavType: Integer; // In / Out: ui to display in the Navigational Pane

TabPos: Integer; // IN / OUT: hhwin_navtab_top, hhwin_navtab_left, or hhwin_navtab_bottom

IDNOTIFY: INTEGER; // IN: ID to use for wm_notify messages

Taborder: Packed Array [0..h_max_tabs] of byte; // in / out: Tab ORDER: Contents, Index, Search, History, Favorites, Reserved 1-5, Custom Tabs

Chistory: Integer; // In / out: Number of History Items to Keep (Default IS 30)

PSZJUMP1: PCHAR; // text for hhwin_button_jump1

PSZJUMP2: PCHAR; // text for hhwin_button_jump2

PSZURLJUMP1: PCHAR; // Url for hhwin_button_jump1

PSZURLJUMP2: PCHAR; // Url for hhwin_button_jump2

Rcminsize: TRECT; // minimum size for WINDOW (Ignored in Version 1)

Cbinfotypes: integer; // size of painfotypes;

Pszcustomtabs: Pchar; // Multiple Zero-Terminated strings

END;

Hh_wintype = taghh_wintype;

ThHWINTYPE = HH_WINTYPE;

Phhwintype = ^ thrhwintype;

Type

HHACT =

HHACT_TAB_CONTENTS, HHACT_TAB_INDEX,

HHACT_TAB_SEARCH,

HHACT_TAB_HISTORY,

HHACT_TAB_FAVORITES,

HHACT_EXPAND,

HHACT_CONTRACT,

HHACT_BACK,

HHACT_FORWARD,

HHACT_STOP,

HHACT_REFRESH,

HHACT_HOME,

HHACT_SYNC,

HHACT_OPTIONS,

HHACT_PRINT,

HHACT_HIGHLIGHT,

HHACT_CUSTOMIZE,

HHACT_JUMP1,

HHACT_JUMP2,

HHACT_ZOOM,

HHACT_TOC_NEXT,

HHACT_TOC_PREV,

HHACT_NOTES,

HHACT_LAST_ENUM);

Type

TAGHHHNTRACK = Packed Record // TAGHHHTRACK, HHNTRACK

HDR: TNMHDR;

Pszcururl: pwidechar; // multi-byte, null-terminated string !! pwidechar; // pcstr: multi-byte, Nul-Terminated String

iDAdition: integer; // hhact_ value

Phhwintype: phhwintype; // Current Window Type Structure

END;

HHNTRACK = taghhntrack;

///

//

// Global Control Properties.

//

Type

TAGHH_GPROPID = INTEGER; // taghh_gpropid, hh_gpropid

HH_GPROPID = tagh_gpropid;

Const

HH_GPROPID_SINGLETHREAD = 1; // Variant_Bool: True for Single Thread

HH_GPROPID_TOOLBAR_MARGIN = 2; // long: provides a left / right margin around the toolbar.

HH_GPROPID_UI_LANGUAGE = 3; // long: langid of the ui.

HH_GPROPID_CURRENT_SUBSET = 4; // BStr: Current Subset.

HH_GPROPID_CONTENT_LANGUAGE = 5; // long: landid for design.

///

//

// Global Property Structure

//

Type

TAGHH_GLOBAL_PROPERTY = PACKED RECORD / / TAGHHH_GLOBAL_PROPERTY, HH_GLOBAL_PROPERTY

ID: hh_gpropid;

Variant;

END;

HH_GLOBAL_PROPERTY = taghh_global_property;

IMPLEMENTATION

Const hhpathregkey = 'CLSID / {ADB880A6-D8FF-11CF-9377-00AA003B7A11} / inprocserver32'; {

Returns Full Path to hhctrl.ocx. Returns Empty String if File or Registry Entry Not Found

Note: hhctrl.ocx may not be in the path. Consider the case where

The Ocx Has Been Downloaded to The Windows Ocx Cache Via The Net.

So .. Best to get the path from the registry

}

Function getPathtohhctrlocx: String;

Var rg: Tregistry;

Begin

Result: = ''; // Default Return

Rg: = tregistry.create;

Rg.RootKey: = HKEY_CLASSES_ROOT;

IF rg.keyexists (hhpathregkey) and rg.openkey (HhpathRegkey, false) THEN

Begin

Result: = rg.readstring (''); // Default Value

Rg.closekey;

IF (Result <> ') and (not fileexists (result)) THEN / FINAL Check - File Must EXIST

Result: = '';

END;

Rg.free;

END;

// Add by LiHD 20040823 As the final entrance, it is provided to HTMLHELP a certain exit to prevent memory access errors.

Function DSHTMLHELP (HWNDCALLER: HWND; PSZFILE: PCHAR; UCommand: cardinal; dwdata: dword): hwd; stdcall;

Begin

Shellapi.SHellexecute (HWndcaller, 'Open', PSZFILE, '', '', SW_NORMAL);

END;

Procedure modulehhhctrl;

VAR OCXFN: String;

Begin

Ocxfn: = getPathtohhctrlocx;

If FileExists (OCXFN) THEN

HHCTRLHANDLE: = loadingLibrary (Pchar (OCXFN))

// add by lihd 20040823

Else

Hhctrlhandle: = loadingLibrary (pchar (hhctrllib));

IF hhctrlhandle <> 0 THEN

Begin

@HTMLHELPA: = GetProcaddress (hhctrlhandle, 'htmlhelpa');

@HTMLHELPW: = GetProcaddress (hhctrlhandle, 'htmlhelpw');

@HTMLHELP: = GetProcaddress (hhctrlhandle, 'htmlhelpa');

end

Else // Add by Lihd 20040823 Take default shellexeccute

Begin

@HTMLHELPA: = @dshtmlhelp;

@HTMLHELPW: = @dshtmlhelp; @htmlhelp: = @dshtmlhelp;

END;

END;

INITIALIZATION

Modulehhctrl;

Finalization

IF hhctrlhandle <> 0 THEN

Freelibrary (hhctrlhandle);

End.

Of course, the best way is to bring a hhctrl.ocx when the software is distributed, and register ... Hehe ...

转载请注明原文地址:https://www.9cbs.com/read-124185.html

New Post(0)