ホーム › System.LibraryLoader › FindResourceW
FindResourceW
関数モジュール内のリソースをUnicode名で検索する。
シグネチャ
// KERNEL32.dll (Unicode / -W)
#include <windows.h>
HRSRC FindResourceW(
HMODULE hModule, // optional
LPCWSTR lpName,
LPCWSTR lpType
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hModule | HMODULE | inoptional |
| lpName | LPCWSTR | in |
| lpType | LPCWSTR | in |
戻り値の型: HRSRC
各言語での呼び出し定義
// KERNEL32.dll (Unicode / -W)
#include <windows.h>
HRSRC FindResourceW(
HMODULE hModule, // optional
LPCWSTR lpName,
LPCWSTR lpType
);[DllImport("KERNEL32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern IntPtr FindResourceW(
IntPtr hModule, // HMODULE optional
[MarshalAs(UnmanagedType.LPWStr)] string lpName, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string lpType // LPCWSTR
);<DllImport("KERNEL32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function FindResourceW(
hModule As IntPtr, ' HMODULE optional
<MarshalAs(UnmanagedType.LPWStr)> lpName As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> lpType As String ' LPCWSTR
) As IntPtr
End Function' hModule : HMODULE optional
' lpName : LPCWSTR
' lpType : LPCWSTR
Declare PtrSafe Function FindResourceW Lib "kernel32" ( _
ByVal hModule As LongPtr, _
ByVal lpName As LongPtr, _
ByVal lpType 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
FindResourceW = ctypes.windll.kernel32.FindResourceW
FindResourceW.restype = ctypes.c_void_p
FindResourceW.argtypes = [
wintypes.HANDLE, # hModule : HMODULE optional
wintypes.LPCWSTR, # lpName : LPCWSTR
wintypes.LPCWSTR, # lpType : LPCWSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
FindResourceW = Fiddle::Function.new(
lib['FindResourceW'],
[
Fiddle::TYPE_VOIDP, # hModule : HMODULE optional
Fiddle::TYPE_VOIDP, # lpName : LPCWSTR
Fiddle::TYPE_VOIDP, # lpType : LPCWSTR
],
Fiddle::TYPE_VOIDP)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "kernel32")]
extern "system" {
fn FindResourceW(
hModule: *mut core::ffi::c_void, // HMODULE optional
lpName: *const u16, // LPCWSTR
lpType: *const u16 // LPCWSTR
) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("KERNEL32.dll", CharSet = CharSet.Unicode)]
public static extern IntPtr FindResourceW(IntPtr hModule, [MarshalAs(UnmanagedType.LPWStr)] string lpName, [MarshalAs(UnmanagedType.LPWStr)] string lpType);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_FindResourceW' -Namespace Win32 -PassThru
# $api::FindResourceW(hModule, lpName, lpType)#uselib "KERNEL32.dll"
#func global FindResourceW "FindResourceW" wptr, wptr, wptr
; FindResourceW hModule, lpName, lpType ; 戻り値は stat
; hModule : HMODULE optional -> "wptr"
; lpName : LPCWSTR -> "wptr"
; lpType : LPCWSTR -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "KERNEL32.dll"
#cfunc global FindResourceW "FindResourceW" sptr, wstr, wstr
; res = FindResourceW(hModule, lpName, lpType)
; hModule : HMODULE optional -> "sptr"
; lpName : LPCWSTR -> "wstr"
; lpType : LPCWSTR -> "wstr"; HRSRC FindResourceW(HMODULE hModule, LPCWSTR lpName, LPCWSTR lpType)
#uselib "KERNEL32.dll"
#cfunc global FindResourceW "FindResourceW" intptr, wstr, wstr
; res = FindResourceW(hModule, lpName, lpType)
; hModule : HMODULE optional -> "intptr"
; lpName : LPCWSTR -> "wstr"
; lpType : LPCWSTR -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procFindResourceW = kernel32.NewProc("FindResourceW")
)
// hModule (HMODULE optional), lpName (LPCWSTR), lpType (LPCWSTR)
r1, _, err := procFindResourceW.Call(
uintptr(hModule),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpName))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpType))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRSRCfunction FindResourceW(
hModule: THandle; // HMODULE optional
lpName: PWideChar; // LPCWSTR
lpType: PWideChar // LPCWSTR
): THandle; stdcall;
external 'KERNEL32.dll' name 'FindResourceW';result := DllCall("KERNEL32\FindResourceW"
, "Ptr", hModule ; HMODULE optional
, "WStr", lpName ; LPCWSTR
, "WStr", lpType ; LPCWSTR
, "Ptr") ; return: HRSRC●FindResourceW(hModule, lpName, lpType) = DLL("KERNEL32.dll", "void* FindResourceW(void*, char*, char*)")
# 呼び出し: FindResourceW(hModule, lpName, lpType)
# hModule : HMODULE optional -> "void*"
# lpName : LPCWSTR -> "char*"
# lpType : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。