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