Win32 API 日本語リファレンス
ホームSystem.LibraryLoader › EnumResourceNamesW

EnumResourceNamesW

関数
指定種類のリソース名をUnicodeで列挙する。
DLLKERNEL32.dll文字セットUnicode (-W)呼出規約winapi

シグネチャ

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

BOOL EnumResourceNamesW(
    HMODULE hModule,   // optional
    LPCWSTR lpType,
    ENUMRESNAMEPROCW lpEnumFunc,
    INT_PTR lParam
);

パラメーター

名前方向
hModuleHMODULEinoptional
lpTypeLPCWSTRin
lpEnumFuncENUMRESNAMEPROCWin
lParamINT_PTRin

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL EnumResourceNamesW(
    HMODULE hModule,   // optional
    LPCWSTR lpType,
    ENUMRESNAMEPROCW lpEnumFunc,
    INT_PTR lParam
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern bool EnumResourceNamesW(
    IntPtr hModule,   // HMODULE optional
    [MarshalAs(UnmanagedType.LPWStr)] string lpType,   // LPCWSTR
    IntPtr lpEnumFunc,   // ENUMRESNAMEPROCW
    IntPtr lParam   // INT_PTR
);
<DllImport("KERNEL32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function EnumResourceNamesW(
    hModule As IntPtr,   ' HMODULE optional
    <MarshalAs(UnmanagedType.LPWStr)> lpType As String,   ' LPCWSTR
    lpEnumFunc As IntPtr,   ' ENUMRESNAMEPROCW
    lParam As IntPtr   ' INT_PTR
) As Boolean
End Function
' hModule : HMODULE optional
' lpType : LPCWSTR
' lpEnumFunc : ENUMRESNAMEPROCW
' lParam : INT_PTR
Declare PtrSafe Function EnumResourceNamesW Lib "kernel32" ( _
    ByVal hModule As LongPtr, _
    ByVal lpType As LongPtr, _
    ByVal lpEnumFunc As LongPtr, _
    ByVal lParam 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

EnumResourceNamesW = ctypes.windll.kernel32.EnumResourceNamesW
EnumResourceNamesW.restype = wintypes.BOOL
EnumResourceNamesW.argtypes = [
    wintypes.HANDLE,  # hModule : HMODULE optional
    wintypes.LPCWSTR,  # lpType : LPCWSTR
    ctypes.c_void_p,  # lpEnumFunc : ENUMRESNAMEPROCW
    ctypes.c_ssize_t,  # lParam : INT_PTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('KERNEL32.dll')
EnumResourceNamesW = Fiddle::Function.new(
  lib['EnumResourceNamesW'],
  [
    Fiddle::TYPE_VOIDP,  # hModule : HMODULE optional
    Fiddle::TYPE_VOIDP,  # lpType : LPCWSTR
    Fiddle::TYPE_VOIDP,  # lpEnumFunc : ENUMRESNAMEPROCW
    Fiddle::TYPE_INTPTR_T,  # lParam : INT_PTR
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "kernel32")]
extern "system" {
    fn EnumResourceNamesW(
        hModule: *mut core::ffi::c_void,  // HMODULE optional
        lpType: *const u16,  // LPCWSTR
        lpEnumFunc: *const core::ffi::c_void,  // ENUMRESNAMEPROCW
        lParam: isize  // INT_PTR
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", CharSet = CharSet.Unicode)]
public static extern bool EnumResourceNamesW(IntPtr hModule, [MarshalAs(UnmanagedType.LPWStr)] string lpType, IntPtr lpEnumFunc, IntPtr lParam);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_EnumResourceNamesW' -Namespace Win32 -PassThru
# $api::EnumResourceNamesW(hModule, lpType, lpEnumFunc, lParam)
#uselib "KERNEL32.dll"
#func global EnumResourceNamesW "EnumResourceNamesW" wptr, wptr, wptr, wptr
; EnumResourceNamesW hModule, lpType, lpEnumFunc, lParam   ; 戻り値は stat
; hModule : HMODULE optional -> "wptr"
; lpType : LPCWSTR -> "wptr"
; lpEnumFunc : ENUMRESNAMEPROCW -> "wptr"
; lParam : INT_PTR -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "KERNEL32.dll"
#cfunc global EnumResourceNamesW "EnumResourceNamesW" sptr, wstr, sptr, sptr
; res = EnumResourceNamesW(hModule, lpType, lpEnumFunc, lParam)
; hModule : HMODULE optional -> "sptr"
; lpType : LPCWSTR -> "wstr"
; lpEnumFunc : ENUMRESNAMEPROCW -> "sptr"
; lParam : INT_PTR -> "sptr"
; BOOL EnumResourceNamesW(HMODULE hModule, LPCWSTR lpType, ENUMRESNAMEPROCW lpEnumFunc, INT_PTR lParam)
#uselib "KERNEL32.dll"
#cfunc global EnumResourceNamesW "EnumResourceNamesW" intptr, wstr, intptr, intptr
; res = EnumResourceNamesW(hModule, lpType, lpEnumFunc, lParam)
; hModule : HMODULE optional -> "intptr"
; lpType : LPCWSTR -> "wstr"
; lpEnumFunc : ENUMRESNAMEPROCW -> "intptr"
; lParam : INT_PTR -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procEnumResourceNamesW = kernel32.NewProc("EnumResourceNamesW")
)

// hModule (HMODULE optional), lpType (LPCWSTR), lpEnumFunc (ENUMRESNAMEPROCW), lParam (INT_PTR)
r1, _, err := procEnumResourceNamesW.Call(
	uintptr(hModule),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpType))),
	uintptr(lpEnumFunc),
	uintptr(lParam),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function EnumResourceNamesW(
  hModule: THandle;   // HMODULE optional
  lpType: PWideChar;   // LPCWSTR
  lpEnumFunc: Pointer;   // ENUMRESNAMEPROCW
  lParam: NativeInt   // INT_PTR
): BOOL; stdcall;
  external 'KERNEL32.dll' name 'EnumResourceNamesW';
result := DllCall("KERNEL32\EnumResourceNamesW"
    , "Ptr", hModule   ; HMODULE optional
    , "WStr", lpType   ; LPCWSTR
    , "Ptr", lpEnumFunc   ; ENUMRESNAMEPROCW
    , "Ptr", lParam   ; INT_PTR
    , "Int")   ; return: BOOL
●EnumResourceNamesW(hModule, lpType, lpEnumFunc, lParam) = DLL("KERNEL32.dll", "bool EnumResourceNamesW(void*, char*, void*, int)")
# 呼び出し: EnumResourceNamesW(hModule, lpType, lpEnumFunc, lParam)
# hModule : HMODULE optional -> "void*"
# lpType : LPCWSTR -> "char*"
# lpEnumFunc : ENUMRESNAMEPROCW -> "void*"
# lParam : INT_PTR -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。