Win32 API 日本語リファレンス
ホームUI.Shell › WinHelpW

WinHelpW

関数
WinHelpヘルプシステムを起動する(Unicode版)。
DLLUSER32.dll文字セットUnicode (-W)呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

// USER32.dll  (Unicode / -W)
#include <windows.h>

BOOL WinHelpW(
    HWND hWndMain,   // optional
    LPCWSTR lpszHelp,   // optional
    DWORD uCommand,
    UINT_PTR dwData
);

パラメーター

名前方向
hWndMainHWNDinoptional
lpszHelpLPCWSTRinoptional
uCommandDWORDin
dwDataUINT_PTRin

戻り値の型: BOOL

各言語での呼び出し定義

// USER32.dll  (Unicode / -W)
#include <windows.h>

BOOL WinHelpW(
    HWND hWndMain,   // optional
    LPCWSTR lpszHelp,   // optional
    DWORD uCommand,
    UINT_PTR dwData
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern bool WinHelpW(
    IntPtr hWndMain,   // HWND optional
    [MarshalAs(UnmanagedType.LPWStr)] string lpszHelp,   // LPCWSTR optional
    uint uCommand,   // DWORD
    UIntPtr dwData   // UINT_PTR
);
<DllImport("USER32.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function WinHelpW(
    hWndMain As IntPtr,   ' HWND optional
    <MarshalAs(UnmanagedType.LPWStr)> lpszHelp As String,   ' LPCWSTR optional
    uCommand As UInteger,   ' DWORD
    dwData As UIntPtr   ' UINT_PTR
) As Boolean
End Function
' hWndMain : HWND optional
' lpszHelp : LPCWSTR optional
' uCommand : DWORD
' dwData : UINT_PTR
Declare PtrSafe Function WinHelpW Lib "user32" ( _
    ByVal hWndMain As LongPtr, _
    ByVal lpszHelp As LongPtr, _
    ByVal uCommand As Long, _
    ByVal dwData As LongPtr) As Long
' 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

WinHelpW = ctypes.windll.user32.WinHelpW
WinHelpW.restype = wintypes.BOOL
WinHelpW.argtypes = [
    wintypes.HANDLE,  # hWndMain : HWND optional
    wintypes.LPCWSTR,  # lpszHelp : LPCWSTR optional
    wintypes.DWORD,  # uCommand : DWORD
    ctypes.c_size_t,  # dwData : UINT_PTR
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

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

var (
	user32 = windows.NewLazySystemDLL("USER32.dll")
	procWinHelpW = user32.NewProc("WinHelpW")
)

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