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