Win32 API 日本語リファレンス
ホームData.HtmlHelp › HtmlHelpW

HtmlHelpW

関数
HTMLヘルプを表示・制御する(Unicode版)。
DLLhhctrl.ocx文字セットUnicode (-W)呼出規約winapi

シグネチャ

// hhctrl.ocx  (Unicode / -W)
#include <windows.h>

HWND HtmlHelpW(
    HWND hwndCaller,   // optional
    LPCWSTR pszFile,
    DWORD uCommand,
    UINT_PTR dwData
);

パラメーター

名前方向説明
hwndCallerHWNDinoptionalヘルプを要求する呼び出し元ウィンドウのハンドル。通知の送信先となる。NULL可。
pszFileLPCWSTRin対象のCHMヘルプファイルパスまたはウィンドウ種別を示すUnicode文字列。コマンドにより意味が変わる。
uCommandDWORDin実行するヘルプ操作を示すコマンド値。HH_DISPLAY_TOPIC等を指定する。
dwDataUINT_PTRinコマンド固有の追加データ。ポインタや整数値としてコマンドに応じ解釈される。

戻り値の型: HWND

各言語での呼び出し定義

// hhctrl.ocx  (Unicode / -W)
#include <windows.h>

HWND HtmlHelpW(
    HWND hwndCaller,   // optional
    LPCWSTR pszFile,
    DWORD uCommand,
    UINT_PTR dwData
);
[DllImport("hhctrl.ocx", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern IntPtr HtmlHelpW(
    IntPtr hwndCaller,   // HWND optional
    [MarshalAs(UnmanagedType.LPWStr)] string pszFile,   // LPCWSTR
    uint uCommand,   // DWORD
    UIntPtr dwData   // UINT_PTR
);
<DllImport("hhctrl.ocx", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function HtmlHelpW(
    hwndCaller As IntPtr,   ' HWND optional
    <MarshalAs(UnmanagedType.LPWStr)> pszFile As String,   ' LPCWSTR
    uCommand As UInteger,   ' DWORD
    dwData As UIntPtr   ' UINT_PTR
) As IntPtr
End Function
' hwndCaller : HWND optional
' pszFile : LPCWSTR
' uCommand : DWORD
' dwData : UINT_PTR
Declare PtrSafe Function HtmlHelpW Lib "hhctrl.ocx" ( _
    ByVal hwndCaller As LongPtr, _
    ByVal pszFile As LongPtr, _
    ByVal uCommand As Long, _
    ByVal dwData As LongPtr) As LongPtr
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

HtmlHelpW = ctypes.windll.LoadLibrary("hhctrl.ocx").HtmlHelpW
HtmlHelpW.restype = ctypes.c_void_p
HtmlHelpW.argtypes = [
    wintypes.HANDLE,  # hwndCaller : HWND optional
    wintypes.LPCWSTR,  # pszFile : LPCWSTR
    wintypes.DWORD,  # uCommand : DWORD
    ctypes.c_size_t,  # dwData : UINT_PTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('hhctrl.ocx')
HtmlHelpW = Fiddle::Function.new(
  lib['HtmlHelpW'],
  [
    Fiddle::TYPE_VOIDP,  # hwndCaller : HWND optional
    Fiddle::TYPE_VOIDP,  # pszFile : LPCWSTR
    -Fiddle::TYPE_INT,  # uCommand : DWORD
    Fiddle::TYPE_UINTPTR_T,  # dwData : UINT_PTR
  ],
  Fiddle::TYPE_VOIDP)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "hhctrl.ocx")]
extern "system" {
    fn HtmlHelpW(
        hwndCaller: *mut core::ffi::c_void,  // HWND optional
        pszFile: *const u16,  // LPCWSTR
        uCommand: u32,  // DWORD
        dwData: usize  // UINT_PTR
    ) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("hhctrl.ocx", CharSet = CharSet.Unicode)]
public static extern IntPtr HtmlHelpW(IntPtr hwndCaller, [MarshalAs(UnmanagedType.LPWStr)] string pszFile, uint uCommand, UIntPtr dwData);
"@
$api = Add-Type -MemberDefinition $sig -Name 'hhctrl.ocx_HtmlHelpW' -Namespace Win32 -PassThru
# $api::HtmlHelpW(hwndCaller, pszFile, uCommand, dwData)
#uselib "hhctrl.ocx"
#func global HtmlHelpW "HtmlHelpW" wptr, wptr, wptr, wptr
; HtmlHelpW hwndCaller, pszFile, uCommand, dwData   ; 戻り値は stat
; hwndCaller : HWND optional -> "wptr"
; pszFile : LPCWSTR -> "wptr"
; uCommand : DWORD -> "wptr"
; dwData : UINT_PTR -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "hhctrl.ocx"
#cfunc global HtmlHelpW "HtmlHelpW" sptr, wstr, int, sptr
; res = HtmlHelpW(hwndCaller, pszFile, uCommand, dwData)
; hwndCaller : HWND optional -> "sptr"
; pszFile : LPCWSTR -> "wstr"
; uCommand : DWORD -> "int"
; dwData : UINT_PTR -> "sptr"
; HWND HtmlHelpW(HWND hwndCaller, LPCWSTR pszFile, DWORD uCommand, UINT_PTR dwData)
#uselib "hhctrl.ocx"
#cfunc global HtmlHelpW "HtmlHelpW" intptr, wstr, int, intptr
; res = HtmlHelpW(hwndCaller, pszFile, uCommand, dwData)
; hwndCaller : HWND optional -> "intptr"
; pszFile : LPCWSTR -> "wstr"
; uCommand : DWORD -> "int"
; dwData : UINT_PTR -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	hhctrl_ocx = windows.NewLazySystemDLL("hhctrl.ocx")
	procHtmlHelpW = hhctrl_ocx.NewProc("HtmlHelpW")
)

// hwndCaller (HWND optional), pszFile (LPCWSTR), uCommand (DWORD), dwData (UINT_PTR)
r1, _, err := procHtmlHelpW.Call(
	uintptr(hwndCaller),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszFile))),
	uintptr(uCommand),
	uintptr(dwData),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HWND
function HtmlHelpW(
  hwndCaller: THandle;   // HWND optional
  pszFile: PWideChar;   // LPCWSTR
  uCommand: DWORD;   // DWORD
  dwData: NativeUInt   // UINT_PTR
): THandle; stdcall;
  external 'hhctrl.ocx' name 'HtmlHelpW';
result := DllCall("hhctrl.ocx\HtmlHelpW"
    , "Ptr", hwndCaller   ; HWND optional
    , "WStr", pszFile   ; LPCWSTR
    , "UInt", uCommand   ; DWORD
    , "UPtr", dwData   ; UINT_PTR
    , "Ptr")   ; return: HWND
●HtmlHelpW(hwndCaller, pszFile, uCommand, dwData) = DLL("hhctrl.ocx", "void* HtmlHelpW(void*, char*, dword, int)")
# 呼び出し: HtmlHelpW(hwndCaller, pszFile, uCommand, dwData)
# hwndCaller : HWND optional -> "void*"
# pszFile : LPCWSTR -> "char*"
# uCommand : DWORD -> "dword"
# dwData : UINT_PTR -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。
const std = @import("std");

extern "hhctrl.ocx" fn HtmlHelpW(
    hwndCaller: ?*anyopaque, // HWND optional
    pszFile: [*c]const u16, // LPCWSTR
    uCommand: u32, // DWORD
    dwData: usize // UINT_PTR
) callconv(std.os.windows.WINAPI) ?*anyopaque;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。
proc HtmlHelpW(
    hwndCaller: pointer,  # HWND optional
    pszFile: WideCString,  # LPCWSTR
    uCommand: uint32,  # DWORD
    dwData: uint  # UINT_PTR
): pointer {.importc: "HtmlHelpW", stdcall, dynlib: "hhctrl.ocx".}
# Unicode(-W): WideCString は newWideCString("...") で生成。
pragma(lib, "hhctrl.ocx");
extern(Windows)
void* HtmlHelpW(
    void* hwndCaller,   // HWND optional
    const(wchar)* pszFile,   // LPCWSTR
    uint uCommand,   // DWORD
    size_t dwData   // UINT_PTR
);
ccall((:HtmlHelpW, "hhctrl.ocx"), stdcall, Ptr{Cvoid},
      (Ptr{Cvoid}, Cwstring, UInt32, Csize_t),
      hwndCaller, pszFile, uCommand, dwData)
# hwndCaller : HWND optional -> Ptr{Cvoid}
# pszFile : LPCWSTR -> Cwstring
# uCommand : DWORD -> UInt32
# dwData : UINT_PTR -> Csize_t
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。
local ffi = require("ffi")
ffi.cdef[[
void* HtmlHelpW(
    void* hwndCaller,
    const uint16_t* pszFile,
    uint32_t uCommand,
    uintptr_t dwData);
]]
local hhctrl.ocx = ffi.load("hhctrl.ocx")
-- hhctrl.ocx.HtmlHelpW(hwndCaller, pszFile, uCommand, dwData)
-- hwndCaller : HWND optional
-- pszFile : LPCWSTR
-- uCommand : DWORD
-- dwData : UINT_PTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。
const koffi = require('koffi');
const lib = koffi.load('hhctrl.ocx');
const HtmlHelpW = lib.func('__stdcall', 'HtmlHelpW', 'void *', ['void *', 'str16', 'uint32_t', 'uintptr_t']);
// HtmlHelpW(hwndCaller, pszFile, uCommand, dwData)
// hwndCaller : HWND optional -> 'void *'
// pszFile : LPCWSTR -> 'str16'
// uCommand : DWORD -> 'uint32_t'
// dwData : UINT_PTR -> 'uintptr_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("hhctrl.ocx", {
  HtmlHelpW: { parameters: ["pointer", "buffer", "u32", "usize"], result: "pointer" },
});
// lib.symbols.HtmlHelpW(hwndCaller, pszFile, uCommand, dwData)
// hwndCaller : HWND optional -> "pointer"
// pszFile : LPCWSTR -> "buffer"
// uCommand : DWORD -> "u32"
// dwData : UINT_PTR -> "usize"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
void* HtmlHelpW(
    void* hwndCaller,
    const uint16_t* pszFile,
    uint32_t uCommand,
    size_t dwData);
C, "hhctrl.ocx");
// $ffi->HtmlHelpW(hwndCaller, pszFile, uCommand, dwData);
// hwndCaller : HWND optional
// pszFile : LPCWSTR
// uCommand : DWORD
// dwData : UINT_PTR
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Hhctrl.ocx extends StdCallLibrary {
    Hhctrl.ocx INSTANCE = Native.load("hhctrl.ocx", Hhctrl.ocx.class, W32APIOptions.UNICODE_OPTIONS);
    Pointer HtmlHelpW(
        Pointer hwndCaller,   // HWND optional
        WString pszFile,   // LPCWSTR
        int uCommand,   // DWORD
        long dwData   // UINT_PTR
    );
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。
@[Link("hhctrl.ocx")]
lib Libhhctrl.ocx
  fun HtmlHelpW = HtmlHelpW(
    hwndCaller : Void*,   # HWND optional
    pszFile : UInt16*,   # LPCWSTR
    uCommand : UInt32,   # DWORD
    dwData : LibC::SizeT   # UINT_PTR
  ) : Void*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef HtmlHelpWNative = Pointer<Void> Function(Pointer<Void>, Pointer<Utf16>, Uint32, UintPtr);
typedef HtmlHelpWDart = Pointer<Void> Function(Pointer<Void>, Pointer<Utf16>, int, int);
final HtmlHelpW = DynamicLibrary.open('hhctrl.ocx')
    .lookupFunction<HtmlHelpWNative, HtmlHelpWDart>('HtmlHelpW');
// hwndCaller : HWND optional -> Pointer<Void>
// pszFile : LPCWSTR -> Pointer<Utf16>
// uCommand : DWORD -> Uint32
// dwData : UINT_PTR -> UintPtr
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function HtmlHelpW(
  hwndCaller: THandle;   // HWND optional
  pszFile: PWideChar;   // LPCWSTR
  uCommand: DWORD;   // DWORD
  dwData: NativeUInt   // UINT_PTR
): THandle; stdcall;
  external 'hhctrl.ocx' name 'HtmlHelpW';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "HtmlHelpW"
  c_HtmlHelpW :: Ptr () -> CWString -> Word32 -> CUIntPtr -> IO (Ptr ())
-- hwndCaller : HWND optional -> Ptr ()
-- pszFile : LPCWSTR -> CWString
-- uCommand : DWORD -> Word32
-- dwData : UINT_PTR -> CUIntPtr
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let htmlhelpw =
  foreign "HtmlHelpW"
    ((ptr void) @-> (ptr uint16_t) @-> uint32_t @-> size_t @-> returning (ptr void))
(* hwndCaller : HWND optional -> (ptr void) *)
(* pszFile : LPCWSTR -> (ptr uint16_t) *)
(* uCommand : DWORD -> uint32_t *)
(* dwData : UINT_PTR -> size_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library hhctrl.ocx (t "hhctrl.ocx"))
(cffi:use-foreign-library hhctrl.ocx)

(cffi:defcfun ("HtmlHelpW" html-help-w :convention :stdcall) :pointer
  (hwnd-caller :pointer)   ; HWND optional
  (psz-file (:string :encoding :utf-16le))   ; LPCWSTR
  (u-command :uint32)   ; DWORD
  (dw-data :uint64))   ; UINT_PTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $HtmlHelpW = Win32::API::More->new('hhctrl.ocx',
    'HANDLE HtmlHelpW(HANDLE hwndCaller, LPCWSTR pszFile, DWORD uCommand, WPARAM dwData)');
# my $ret = $HtmlHelpW->Call($hwndCaller, $pszFile, $uCommand, $dwData);
# hwndCaller : HWND optional -> HANDLE
# pszFile : LPCWSTR -> LPCWSTR
# uCommand : DWORD -> DWORD
# dwData : UINT_PTR -> WPARAM
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。

関連項目

文字セット違い