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