Win32 API 日本語リファレンス
ホームGraphics.Gdi › RestoreDC

RestoreDC

関数
保存しておいたDCの状態を復元する。
DLLGDI32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

BOOL RestoreDC(
    HDC hdc,
    INT nSavedDC
);

パラメーター

名前方向
hdcHDCin
nSavedDCINTin

戻り値の型: BOOL

各言語での呼び出し定義

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

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

RestoreDC = ctypes.windll.gdi32.RestoreDC
RestoreDC.restype = wintypes.BOOL
RestoreDC.argtypes = [
    wintypes.HANDLE,  # hdc : HDC
    ctypes.c_int,  # nSavedDC : INT
]
require 'fiddle'
require 'fiddle/import'

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

var (
	gdi32 = windows.NewLazySystemDLL("GDI32.dll")
	procRestoreDC = gdi32.NewProc("RestoreDC")
)

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