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

InvalidateConsoleDIBits

関数
コンソール画面の指定矩形領域を無効化して再描画させる。
DLLKERNEL32.dll呼出規約winapi

シグネチャ

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

BOOL InvalidateConsoleDIBits(
    HANDLE hConsoleOutput,
    SMALL_RECT* lpRect
);

パラメーター

名前方向
hConsoleOutputHANDLEin
lpRectSMALL_RECT*in

戻り値の型: BOOL

各言語での呼び出し定義

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

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

InvalidateConsoleDIBits = ctypes.windll.kernel32.InvalidateConsoleDIBits
InvalidateConsoleDIBits.restype = wintypes.BOOL
InvalidateConsoleDIBits.argtypes = [
    wintypes.HANDLE,  # hConsoleOutput : HANDLE
    ctypes.c_void_p,  # lpRect : SMALL_RECT*
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('KERNEL32.dll')
InvalidateConsoleDIBits = Fiddle::Function.new(
  lib['InvalidateConsoleDIBits'],
  [
    Fiddle::TYPE_VOIDP,  # hConsoleOutput : HANDLE
    Fiddle::TYPE_VOIDP,  # lpRect : SMALL_RECT*
  ],
  Fiddle::TYPE_INT)
#[link(name = "kernel32")]
extern "system" {
    fn InvalidateConsoleDIBits(
        hConsoleOutput: *mut core::ffi::c_void,  // HANDLE
        lpRect: *mut SMALL_RECT  // SMALL_RECT*
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll")]
public static extern bool InvalidateConsoleDIBits(IntPtr hConsoleOutput, IntPtr lpRect);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_InvalidateConsoleDIBits' -Namespace Win32 -PassThru
# $api::InvalidateConsoleDIBits(hConsoleOutput, lpRect)
#uselib "KERNEL32.dll"
#func global InvalidateConsoleDIBits "InvalidateConsoleDIBits" sptr, sptr
; InvalidateConsoleDIBits hConsoleOutput, varptr(lpRect)   ; 戻り値は stat
; hConsoleOutput : HANDLE -> "sptr"
; lpRect : SMALL_RECT* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "KERNEL32.dll"
#cfunc global InvalidateConsoleDIBits "InvalidateConsoleDIBits" sptr, var
; res = InvalidateConsoleDIBits(hConsoleOutput, lpRect)
; hConsoleOutput : HANDLE -> "sptr"
; lpRect : SMALL_RECT* -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL InvalidateConsoleDIBits(HANDLE hConsoleOutput, SMALL_RECT* lpRect)
#uselib "KERNEL32.dll"
#cfunc global InvalidateConsoleDIBits "InvalidateConsoleDIBits" intptr, var
; res = InvalidateConsoleDIBits(hConsoleOutput, lpRect)
; hConsoleOutput : HANDLE -> "intptr"
; lpRect : SMALL_RECT* -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procInvalidateConsoleDIBits = kernel32.NewProc("InvalidateConsoleDIBits")
)

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