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