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