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再描画(無効化)する画面領域を示すSMALL_RECT構造体へのポインタ。

戻り値の型: 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 <MarshalAs(UnmanagedType.Bool)> 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)。
const std = @import("std");

extern "kernel32" fn InvalidateConsoleDIBits(
    hConsoleOutput: ?*anyopaque, // HANDLE
    lpRect: [*c]SMALL_RECT // SMALL_RECT*
) callconv(std.os.windows.WINAPI) i32;
proc InvalidateConsoleDIBits(
    hConsoleOutput: pointer,  # HANDLE
    lpRect: ptr SMALL_RECT  # SMALL_RECT*
): int32 {.importc: "InvalidateConsoleDIBits", stdcall, dynlib: "KERNEL32.dll".}
pragma(lib, "kernel32");
extern(Windows)
int InvalidateConsoleDIBits(
    void* hConsoleOutput,   // HANDLE
    SMALL_RECT* lpRect   // SMALL_RECT*
);
ccall((:InvalidateConsoleDIBits, "KERNEL32.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Ptr{SMALL_RECT}),
      hConsoleOutput, lpRect)
# hConsoleOutput : HANDLE -> Ptr{Cvoid}
# lpRect : SMALL_RECT* -> Ptr{SMALL_RECT}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t InvalidateConsoleDIBits(
    void* hConsoleOutput,
    void* lpRect);
]]
local kernel32 = ffi.load("kernel32")
-- kernel32.InvalidateConsoleDIBits(hConsoleOutput, lpRect)
-- hConsoleOutput : HANDLE
-- lpRect : SMALL_RECT*
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('KERNEL32.dll');
const InvalidateConsoleDIBits = lib.func('__stdcall', 'InvalidateConsoleDIBits', 'int32_t', ['void *', 'void *']);
// InvalidateConsoleDIBits(hConsoleOutput, lpRect)
// hConsoleOutput : HANDLE -> 'void *'
// lpRect : SMALL_RECT* -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("KERNEL32.dll", {
  InvalidateConsoleDIBits: { parameters: ["pointer", "pointer"], result: "i32" },
});
// lib.symbols.InvalidateConsoleDIBits(hConsoleOutput, lpRect)
// hConsoleOutput : HANDLE -> "pointer"
// lpRect : SMALL_RECT* -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t InvalidateConsoleDIBits(
    void* hConsoleOutput,
    void* lpRect);
C, "KERNEL32.dll");
// $ffi->InvalidateConsoleDIBits(hConsoleOutput, lpRect);
// hConsoleOutput : HANDLE
// lpRect : SMALL_RECT*
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Kernel32 extends StdCallLibrary {
    Kernel32 INSTANCE = Native.load("kernel32", Kernel32.class);
    boolean InvalidateConsoleDIBits(
        Pointer hConsoleOutput,   // HANDLE
        Pointer lpRect   // SMALL_RECT*
    );
}
@[Link("kernel32")]
lib LibKERNEL32
  fun InvalidateConsoleDIBits = InvalidateConsoleDIBits(
    hConsoleOutput : Void*,   # HANDLE
    lpRect : SMALL_RECT*   # SMALL_RECT*
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef InvalidateConsoleDIBitsNative = Int32 Function(Pointer<Void>, Pointer<Void>);
typedef InvalidateConsoleDIBitsDart = int Function(Pointer<Void>, Pointer<Void>);
final InvalidateConsoleDIBits = DynamicLibrary.open('KERNEL32.dll')
    .lookupFunction<InvalidateConsoleDIBitsNative, InvalidateConsoleDIBitsDart>('InvalidateConsoleDIBits');
// hConsoleOutput : HANDLE -> Pointer<Void>
// lpRect : SMALL_RECT* -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function InvalidateConsoleDIBits(
  hConsoleOutput: THandle;   // HANDLE
  lpRect: Pointer   // SMALL_RECT*
): BOOL; stdcall;
  external 'KERNEL32.dll' name 'InvalidateConsoleDIBits';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "InvalidateConsoleDIBits"
  c_InvalidateConsoleDIBits :: Ptr () -> Ptr () -> IO CInt
-- hConsoleOutput : HANDLE -> Ptr ()
-- lpRect : SMALL_RECT* -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let invalidateconsoledibits =
  foreign "InvalidateConsoleDIBits"
    ((ptr void) @-> (ptr void) @-> returning int32_t)
(* hConsoleOutput : HANDLE -> (ptr void) *)
(* lpRect : SMALL_RECT* -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library kernel32 (t "KERNEL32.dll"))
(cffi:use-foreign-library kernel32)

(cffi:defcfun ("InvalidateConsoleDIBits" invalidate-console-dibits :convention :stdcall) :int32
  (h-console-output :pointer)   ; HANDLE
  (lp-rect :pointer))   ; SMALL_RECT*
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $InvalidateConsoleDIBits = Win32::API::More->new('KERNEL32',
    'BOOL InvalidateConsoleDIBits(HANDLE hConsoleOutput, LPVOID lpRect)');
# my $ret = $InvalidateConsoleDIBits->Call($hConsoleOutput, $lpRect);
# hConsoleOutput : HANDLE -> HANDLE
# lpRect : SMALL_RECT* -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型