Win32 API 日本語リファレンス
ホームSystem.Console › SetConsoleMenuClose

SetConsoleMenuClose

関数
コンソールのシステムメニューの閉じる項目の有効性を設定する。
DLLKERNEL32.dll呼出規約winapi

シグネチャ

// KERNEL32.dll
#include <windows.h>

BOOL SetConsoleMenuClose(
    BOOL bEnable
);

パラメーター

名前方向
bEnableBOOLin

戻り値の型: BOOL

各言語での呼び出し定義

// KERNEL32.dll
#include <windows.h>

BOOL SetConsoleMenuClose(
    BOOL bEnable
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", ExactSpelling = true)]
static extern bool SetConsoleMenuClose(
    bool bEnable   // BOOL
);
<DllImport("KERNEL32.dll", ExactSpelling:=True)>
Public Shared Function SetConsoleMenuClose(
    bEnable As Boolean   ' BOOL
) As Boolean
End Function
' bEnable : BOOL
Declare PtrSafe Function SetConsoleMenuClose Lib "kernel32" ( _
    ByVal bEnable As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SetConsoleMenuClose = ctypes.windll.kernel32.SetConsoleMenuClose
SetConsoleMenuClose.restype = wintypes.BOOL
SetConsoleMenuClose.argtypes = [
    wintypes.BOOL,  # bEnable : BOOL
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('KERNEL32.dll')
SetConsoleMenuClose = Fiddle::Function.new(
  lib['SetConsoleMenuClose'],
  [
    Fiddle::TYPE_INT,  # bEnable : BOOL
  ],
  Fiddle::TYPE_INT)
#[link(name = "kernel32")]
extern "system" {
    fn SetConsoleMenuClose(
        bEnable: i32  // BOOL
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll")]
public static extern bool SetConsoleMenuClose(bool bEnable);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_SetConsoleMenuClose' -Namespace Win32 -PassThru
# $api::SetConsoleMenuClose(bEnable)
#uselib "KERNEL32.dll"
#func global SetConsoleMenuClose "SetConsoleMenuClose" sptr
; SetConsoleMenuClose bEnable   ; 戻り値は stat
; bEnable : BOOL -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "KERNEL32.dll"
#cfunc global SetConsoleMenuClose "SetConsoleMenuClose" int
; res = SetConsoleMenuClose(bEnable)
; bEnable : BOOL -> "int"
; BOOL SetConsoleMenuClose(BOOL bEnable)
#uselib "KERNEL32.dll"
#cfunc global SetConsoleMenuClose "SetConsoleMenuClose" int
; res = SetConsoleMenuClose(bEnable)
; bEnable : BOOL -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procSetConsoleMenuClose = kernel32.NewProc("SetConsoleMenuClose")
)

// bEnable (BOOL)
r1, _, err := procSetConsoleMenuClose.Call(
	uintptr(bEnable),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function SetConsoleMenuClose(
  bEnable: BOOL   // BOOL
): BOOL; stdcall;
  external 'KERNEL32.dll' name 'SetConsoleMenuClose';
result := DllCall("KERNEL32\SetConsoleMenuClose"
    , "Int", bEnable   ; BOOL
    , "Int")   ; return: BOOL
●SetConsoleMenuClose(bEnable) = DLL("KERNEL32.dll", "bool SetConsoleMenuClose(bool)")
# 呼び出し: SetConsoleMenuClose(bEnable)
# bEnable : BOOL -> "bool"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。