有许多人问过这个问题,只可惜 CSDN 的搜索功能太差,所以我只好一遍又一遍的 COPY/PASTE。呵呵,算你幸运,把例子中的 .CHM 路径适当替换一下:PUBLIC.BAS:
==================================================
Option Explicit'hWnd
'WINAPI
'HtmlHelpA(
' HWND hwndCaller,
' LPCSTR pszFile,
' UINT uCommand,
' DWORD_PTR dwData
' );
'
'#define HH_DISPLAY_TOPIC 0x0000
'#define HH_HELP_FINDER 0x0000 // WinHelp equivalent
'#define HH_DISPLAY_TOC 0x0001
'#define HH_DISPLAY_INDEX 0x0002
'#define HH_DISPLAY_SEARCH 0x0003Public Declare Function HTMLHELP Lib "HHCTRL.OCX" Alias "HtmlHelpA" ( _
ByVal hwndCaller As Long, _
ByVal pszFile As String, _
ByVal uCommand As Long, _
ByVal dwData As Any) As Long
Public Const HH_DISPLAY_TOPIC = 0
Public Const HH_HELP_FINDER = 0
Public Const HH_DISPLAY_TOC = 1
Public Const HH_DISPLAY_INDEX = 2
Public Const HH_DISPLAY_SEARCH = 3'typedef struct tagHH_FTS_QUERY
Type HH_FTS_QUERY
' int cbStruct; // Sizeof structure in bytes.
cbStruct As Long
' BOOL fUniCodeStrings; // TRUE if all strings are unicode.
fUniCodeStrings As Long
' LPCTSTR pszSearchQuery; // String containing the search query.
pszSearchQuery As String
' LONG iProximity; // Word proximity.
iProximity As Long
' BOOL fStemmedSearch; // TRUE for StemmedSearch only.
fStemmedSearch As Long
' BOOL fTitleOnly; // TRUE for Title search only.
fTitleOnly As Long
' BOOL fExecute; // TRUE to initiate the search.
fExecute As Long
' LPCTSTR pszWindow; // Window to display in
pszWindow As String
'} HH_FTS_QUERY;
End TypefrmMain.FRM:
==================================================
Option ExplicitPrivate Sub Command1_Click()
Dim h As Long
Dim strTopic As String
strTopic = "abort method"
h = HTMLHELP(Me.hWnd, "C:\My Documents\BOOKS\xmlsdk25.chm", HH_DISPLAY_INDEX, strTopic)
Debug.Print h
End SubPrivate Sub Command2_Click()
Dim h As Long
h = HTMLHELP(Me.hWnd, "C:\My Documents\BOOKS\xmlsdk25.chm::/htm/xmmscxmldomenumeratedconstants.htm", HH_DISPLAY_TOPIC, vbNullString)
Debug.Print h
End SubPrivate Sub Command3_Click()
Dim h As Long
Dim qry As HH_FTS_QUERY
qry.cbStruct = Len(qry)
qry.fExecute = False
qry.fStemmedSearch = False
qry.fTitleOnly = False
qry.fUniCodeStrings = False
qry.iProximity = 0
qry.pszSearchQuery = "XML AND XSL"
qry.pszWindow = ""
h = HTMLHELP(Me.hWnd, "C:\My Documents\BOOKS\xmlsdk25.chm", HH_DISPLAY_SEARCH, VarPtr(qry))
Debug.Print h
End Sub
==================================================
Option Explicit'hWnd
'WINAPI
'HtmlHelpA(
' HWND hwndCaller,
' LPCSTR pszFile,
' UINT uCommand,
' DWORD_PTR dwData
' );
'
'#define HH_DISPLAY_TOPIC 0x0000
'#define HH_HELP_FINDER 0x0000 // WinHelp equivalent
'#define HH_DISPLAY_TOC 0x0001
'#define HH_DISPLAY_INDEX 0x0002
'#define HH_DISPLAY_SEARCH 0x0003Public Declare Function HTMLHELP Lib "HHCTRL.OCX" Alias "HtmlHelpA" ( _
ByVal hwndCaller As Long, _
ByVal pszFile As String, _
ByVal uCommand As Long, _
ByVal dwData As Any) As Long
Public Const HH_DISPLAY_TOPIC = 0
Public Const HH_HELP_FINDER = 0
Public Const HH_DISPLAY_TOC = 1
Public Const HH_DISPLAY_INDEX = 2
Public Const HH_DISPLAY_SEARCH = 3'typedef struct tagHH_FTS_QUERY
Type HH_FTS_QUERY
' int cbStruct; // Sizeof structure in bytes.
cbStruct As Long
' BOOL fUniCodeStrings; // TRUE if all strings are unicode.
fUniCodeStrings As Long
' LPCTSTR pszSearchQuery; // String containing the search query.
pszSearchQuery As String
' LONG iProximity; // Word proximity.
iProximity As Long
' BOOL fStemmedSearch; // TRUE for StemmedSearch only.
fStemmedSearch As Long
' BOOL fTitleOnly; // TRUE for Title search only.
fTitleOnly As Long
' BOOL fExecute; // TRUE to initiate the search.
fExecute As Long
' LPCTSTR pszWindow; // Window to display in
pszWindow As String
'} HH_FTS_QUERY;
End TypefrmMain.FRM:
==================================================
Option ExplicitPrivate Sub Command1_Click()
Dim h As Long
Dim strTopic As String
strTopic = "abort method"
h = HTMLHELP(Me.hWnd, "C:\My Documents\BOOKS\xmlsdk25.chm", HH_DISPLAY_INDEX, strTopic)
Debug.Print h
End SubPrivate Sub Command2_Click()
Dim h As Long
h = HTMLHELP(Me.hWnd, "C:\My Documents\BOOKS\xmlsdk25.chm::/htm/xmmscxmldomenumeratedconstants.htm", HH_DISPLAY_TOPIC, vbNullString)
Debug.Print h
End SubPrivate Sub Command3_Click()
Dim h As Long
Dim qry As HH_FTS_QUERY
qry.cbStruct = Len(qry)
qry.fExecute = False
qry.fStemmedSearch = False
qry.fTitleOnly = False
qry.fUniCodeStrings = False
qry.iProximity = 0
qry.pszSearchQuery = "XML AND XSL"
qry.pszWindow = ""
h = HTMLHELP(Me.hWnd, "C:\My Documents\BOOKS\xmlsdk25.chm", HH_DISPLAY_SEARCH, VarPtr(qry))
Debug.Print h
End Sub
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货