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