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