Win32 API 日本語リファレンス
ホームDevices.Display › DestroyPhysicalMonitors

DestroyPhysicalMonitors

関数
物理モニタのハンドル配列をまとめて破棄する。
DLLdxva2.dll呼出規約winapiSetLastErrorあり対応OSWindows Vista 以降

シグネチャ

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

BOOL DestroyPhysicalMonitors(
    DWORD dwPhysicalMonitorArraySize,
    PHYSICAL_MONITOR* pPhysicalMonitorArray
);

パラメーター

名前方向
dwPhysicalMonitorArraySizeDWORDin
pPhysicalMonitorArrayPHYSICAL_MONITOR*in

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL DestroyPhysicalMonitors(
    DWORD dwPhysicalMonitorArraySize,
    PHYSICAL_MONITOR* pPhysicalMonitorArray
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("dxva2.dll", SetLastError = true, ExactSpelling = true)]
static extern bool DestroyPhysicalMonitors(
    uint dwPhysicalMonitorArraySize,   // DWORD
    IntPtr pPhysicalMonitorArray   // PHYSICAL_MONITOR*
);
<DllImport("dxva2.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function DestroyPhysicalMonitors(
    dwPhysicalMonitorArraySize As UInteger,   ' DWORD
    pPhysicalMonitorArray As IntPtr   ' PHYSICAL_MONITOR*
) As Boolean
End Function
' dwPhysicalMonitorArraySize : DWORD
' pPhysicalMonitorArray : PHYSICAL_MONITOR*
Declare PtrSafe Function DestroyPhysicalMonitors Lib "dxva2" ( _
    ByVal dwPhysicalMonitorArraySize As Long, _
    ByVal pPhysicalMonitorArray As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

DestroyPhysicalMonitors = ctypes.windll.dxva2.DestroyPhysicalMonitors
DestroyPhysicalMonitors.restype = wintypes.BOOL
DestroyPhysicalMonitors.argtypes = [
    wintypes.DWORD,  # dwPhysicalMonitorArraySize : DWORD
    ctypes.c_void_p,  # pPhysicalMonitorArray : PHYSICAL_MONITOR*
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

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

var (
	dxva2 = windows.NewLazySystemDLL("dxva2.dll")
	procDestroyPhysicalMonitors = dxva2.NewProc("DestroyPhysicalMonitors")
)

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