ホーム › UI.WindowsAndMessaging › GetMenuBarInfo
GetMenuBarInfo
関数指定ウィンドウのメニューバー情報を取得する。
シグネチャ
// USER32.dll
#include <windows.h>
BOOL GetMenuBarInfo(
HWND hwnd,
OBJECT_IDENTIFIER idObject,
INT idItem,
MENUBARINFO* pmbi
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hwnd | HWND | in |
| idObject | OBJECT_IDENTIFIER | in |
| idItem | INT | in |
| pmbi | MENUBARINFO* | inout |
戻り値の型: BOOL
各言語での呼び出し定義
// USER32.dll
#include <windows.h>
BOOL GetMenuBarInfo(
HWND hwnd,
OBJECT_IDENTIFIER idObject,
INT idItem,
MENUBARINFO* pmbi
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool GetMenuBarInfo(
IntPtr hwnd, // HWND
int idObject, // OBJECT_IDENTIFIER
int idItem, // INT
IntPtr pmbi // MENUBARINFO* in/out
);<DllImport("USER32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetMenuBarInfo(
hwnd As IntPtr, ' HWND
idObject As Integer, ' OBJECT_IDENTIFIER
idItem As Integer, ' INT
pmbi As IntPtr ' MENUBARINFO* in/out
) As Boolean
End Function' hwnd : HWND
' idObject : OBJECT_IDENTIFIER
' idItem : INT
' pmbi : MENUBARINFO* in/out
Declare PtrSafe Function GetMenuBarInfo Lib "user32" ( _
ByVal hwnd As LongPtr, _
ByVal idObject As Long, _
ByVal idItem As Long, _
ByVal pmbi As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetMenuBarInfo = ctypes.windll.user32.GetMenuBarInfo
GetMenuBarInfo.restype = wintypes.BOOL
GetMenuBarInfo.argtypes = [
wintypes.HANDLE, # hwnd : HWND
ctypes.c_int, # idObject : OBJECT_IDENTIFIER
ctypes.c_int, # idItem : INT
ctypes.c_void_p, # pmbi : MENUBARINFO* in/out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('USER32.dll')
GetMenuBarInfo = Fiddle::Function.new(
lib['GetMenuBarInfo'],
[
Fiddle::TYPE_VOIDP, # hwnd : HWND
Fiddle::TYPE_INT, # idObject : OBJECT_IDENTIFIER
Fiddle::TYPE_INT, # idItem : INT
Fiddle::TYPE_VOIDP, # pmbi : MENUBARINFO* in/out
],
Fiddle::TYPE_INT)#[link(name = "user32")]
extern "system" {
fn GetMenuBarInfo(
hwnd: *mut core::ffi::c_void, // HWND
idObject: i32, // OBJECT_IDENTIFIER
idItem: i32, // INT
pmbi: *mut MENUBARINFO // MENUBARINFO* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", SetLastError = true)]
public static extern bool GetMenuBarInfo(IntPtr hwnd, int idObject, int idItem, IntPtr pmbi);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_GetMenuBarInfo' -Namespace Win32 -PassThru
# $api::GetMenuBarInfo(hwnd, idObject, idItem, pmbi)#uselib "USER32.dll"
#func global GetMenuBarInfo "GetMenuBarInfo" sptr, sptr, sptr, sptr
; GetMenuBarInfo hwnd, idObject, idItem, varptr(pmbi) ; 戻り値は stat
; hwnd : HWND -> "sptr"
; idObject : OBJECT_IDENTIFIER -> "sptr"
; idItem : INT -> "sptr"
; pmbi : MENUBARINFO* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "USER32.dll" #cfunc global GetMenuBarInfo "GetMenuBarInfo" sptr, int, int, var ; res = GetMenuBarInfo(hwnd, idObject, idItem, pmbi) ; hwnd : HWND -> "sptr" ; idObject : OBJECT_IDENTIFIER -> "int" ; idItem : INT -> "int" ; pmbi : MENUBARINFO* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "USER32.dll" #cfunc global GetMenuBarInfo "GetMenuBarInfo" sptr, int, int, sptr ; res = GetMenuBarInfo(hwnd, idObject, idItem, varptr(pmbi)) ; hwnd : HWND -> "sptr" ; idObject : OBJECT_IDENTIFIER -> "int" ; idItem : INT -> "int" ; pmbi : MENUBARINFO* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL GetMenuBarInfo(HWND hwnd, OBJECT_IDENTIFIER idObject, INT idItem, MENUBARINFO* pmbi) #uselib "USER32.dll" #cfunc global GetMenuBarInfo "GetMenuBarInfo" intptr, int, int, var ; res = GetMenuBarInfo(hwnd, idObject, idItem, pmbi) ; hwnd : HWND -> "intptr" ; idObject : OBJECT_IDENTIFIER -> "int" ; idItem : INT -> "int" ; pmbi : MENUBARINFO* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL GetMenuBarInfo(HWND hwnd, OBJECT_IDENTIFIER idObject, INT idItem, MENUBARINFO* pmbi) #uselib "USER32.dll" #cfunc global GetMenuBarInfo "GetMenuBarInfo" intptr, int, int, intptr ; res = GetMenuBarInfo(hwnd, idObject, idItem, varptr(pmbi)) ; hwnd : HWND -> "intptr" ; idObject : OBJECT_IDENTIFIER -> "int" ; idItem : INT -> "int" ; pmbi : MENUBARINFO* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
user32 = windows.NewLazySystemDLL("USER32.dll")
procGetMenuBarInfo = user32.NewProc("GetMenuBarInfo")
)
// hwnd (HWND), idObject (OBJECT_IDENTIFIER), idItem (INT), pmbi (MENUBARINFO* in/out)
r1, _, err := procGetMenuBarInfo.Call(
uintptr(hwnd),
uintptr(idObject),
uintptr(idItem),
uintptr(pmbi),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction GetMenuBarInfo(
hwnd: THandle; // HWND
idObject: Integer; // OBJECT_IDENTIFIER
idItem: Integer; // INT
pmbi: Pointer // MENUBARINFO* in/out
): BOOL; stdcall;
external 'USER32.dll' name 'GetMenuBarInfo';result := DllCall("USER32\GetMenuBarInfo"
, "Ptr", hwnd ; HWND
, "Int", idObject ; OBJECT_IDENTIFIER
, "Int", idItem ; INT
, "Ptr", pmbi ; MENUBARINFO* in/out
, "Int") ; return: BOOL●GetMenuBarInfo(hwnd, idObject, idItem, pmbi) = DLL("USER32.dll", "bool GetMenuBarInfo(void*, int, int, void*)")
# 呼び出し: GetMenuBarInfo(hwnd, idObject, idItem, pmbi)
# hwnd : HWND -> "void*"
# idObject : OBJECT_IDENTIFIER -> "int"
# idItem : INT -> "int"
# pmbi : MENUBARINFO* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。