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