ホーム › Devices.Display › GetPhysicalMonitorsFromHMONITOR
GetPhysicalMonitorsFromHMONITOR
関数HMONITORから物理モニタのハンドル配列を取得する。
シグネチャ
// dxva2.dll
#include <windows.h>
BOOL GetPhysicalMonitorsFromHMONITOR(
HMONITOR hMonitor,
DWORD dwPhysicalMonitorArraySize,
PHYSICAL_MONITOR* pPhysicalMonitorArray
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hMonitor | HMONITOR | in |
| dwPhysicalMonitorArraySize | DWORD | in |
| pPhysicalMonitorArray | PHYSICAL_MONITOR* | out |
戻り値の型: BOOL
各言語での呼び出し定義
// dxva2.dll
#include <windows.h>
BOOL GetPhysicalMonitorsFromHMONITOR(
HMONITOR hMonitor,
DWORD dwPhysicalMonitorArraySize,
PHYSICAL_MONITOR* pPhysicalMonitorArray
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("dxva2.dll", SetLastError = true, ExactSpelling = true)]
static extern bool GetPhysicalMonitorsFromHMONITOR(
IntPtr hMonitor, // HMONITOR
uint dwPhysicalMonitorArraySize, // DWORD
IntPtr pPhysicalMonitorArray // PHYSICAL_MONITOR* out
);<DllImport("dxva2.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetPhysicalMonitorsFromHMONITOR(
hMonitor As IntPtr, ' HMONITOR
dwPhysicalMonitorArraySize As UInteger, ' DWORD
pPhysicalMonitorArray As IntPtr ' PHYSICAL_MONITOR* out
) As Boolean
End Function' hMonitor : HMONITOR
' dwPhysicalMonitorArraySize : DWORD
' pPhysicalMonitorArray : PHYSICAL_MONITOR* out
Declare PtrSafe Function GetPhysicalMonitorsFromHMONITOR Lib "dxva2" ( _
ByVal hMonitor As LongPtr, _
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
GetPhysicalMonitorsFromHMONITOR = ctypes.windll.dxva2.GetPhysicalMonitorsFromHMONITOR
GetPhysicalMonitorsFromHMONITOR.restype = wintypes.BOOL
GetPhysicalMonitorsFromHMONITOR.argtypes = [
wintypes.HANDLE, # hMonitor : HMONITOR
wintypes.DWORD, # dwPhysicalMonitorArraySize : DWORD
ctypes.c_void_p, # pPhysicalMonitorArray : PHYSICAL_MONITOR* out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('dxva2.dll')
GetPhysicalMonitorsFromHMONITOR = Fiddle::Function.new(
lib['GetPhysicalMonitorsFromHMONITOR'],
[
Fiddle::TYPE_VOIDP, # hMonitor : HMONITOR
-Fiddle::TYPE_INT, # dwPhysicalMonitorArraySize : DWORD
Fiddle::TYPE_VOIDP, # pPhysicalMonitorArray : PHYSICAL_MONITOR* out
],
Fiddle::TYPE_INT)#[link(name = "dxva2")]
extern "system" {
fn GetPhysicalMonitorsFromHMONITOR(
hMonitor: *mut core::ffi::c_void, // HMONITOR
dwPhysicalMonitorArraySize: u32, // DWORD
pPhysicalMonitorArray: *mut PHYSICAL_MONITOR // PHYSICAL_MONITOR* out
) -> 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 GetPhysicalMonitorsFromHMONITOR(IntPtr hMonitor, uint dwPhysicalMonitorArraySize, IntPtr pPhysicalMonitorArray);
"@
$api = Add-Type -MemberDefinition $sig -Name 'dxva2_GetPhysicalMonitorsFromHMONITOR' -Namespace Win32 -PassThru
# $api::GetPhysicalMonitorsFromHMONITOR(hMonitor, dwPhysicalMonitorArraySize, pPhysicalMonitorArray)#uselib "dxva2.dll"
#func global GetPhysicalMonitorsFromHMONITOR "GetPhysicalMonitorsFromHMONITOR" sptr, sptr, sptr
; GetPhysicalMonitorsFromHMONITOR hMonitor, dwPhysicalMonitorArraySize, varptr(pPhysicalMonitorArray) ; 戻り値は stat
; hMonitor : HMONITOR -> "sptr"
; dwPhysicalMonitorArraySize : DWORD -> "sptr"
; pPhysicalMonitorArray : PHYSICAL_MONITOR* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "dxva2.dll" #cfunc global GetPhysicalMonitorsFromHMONITOR "GetPhysicalMonitorsFromHMONITOR" sptr, int, var ; res = GetPhysicalMonitorsFromHMONITOR(hMonitor, dwPhysicalMonitorArraySize, pPhysicalMonitorArray) ; hMonitor : HMONITOR -> "sptr" ; dwPhysicalMonitorArraySize : DWORD -> "int" ; pPhysicalMonitorArray : PHYSICAL_MONITOR* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "dxva2.dll" #cfunc global GetPhysicalMonitorsFromHMONITOR "GetPhysicalMonitorsFromHMONITOR" sptr, int, sptr ; res = GetPhysicalMonitorsFromHMONITOR(hMonitor, dwPhysicalMonitorArraySize, varptr(pPhysicalMonitorArray)) ; hMonitor : HMONITOR -> "sptr" ; dwPhysicalMonitorArraySize : DWORD -> "int" ; pPhysicalMonitorArray : PHYSICAL_MONITOR* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL GetPhysicalMonitorsFromHMONITOR(HMONITOR hMonitor, DWORD dwPhysicalMonitorArraySize, PHYSICAL_MONITOR* pPhysicalMonitorArray) #uselib "dxva2.dll" #cfunc global GetPhysicalMonitorsFromHMONITOR "GetPhysicalMonitorsFromHMONITOR" intptr, int, var ; res = GetPhysicalMonitorsFromHMONITOR(hMonitor, dwPhysicalMonitorArraySize, pPhysicalMonitorArray) ; hMonitor : HMONITOR -> "intptr" ; dwPhysicalMonitorArraySize : DWORD -> "int" ; pPhysicalMonitorArray : PHYSICAL_MONITOR* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL GetPhysicalMonitorsFromHMONITOR(HMONITOR hMonitor, DWORD dwPhysicalMonitorArraySize, PHYSICAL_MONITOR* pPhysicalMonitorArray) #uselib "dxva2.dll" #cfunc global GetPhysicalMonitorsFromHMONITOR "GetPhysicalMonitorsFromHMONITOR" intptr, int, intptr ; res = GetPhysicalMonitorsFromHMONITOR(hMonitor, dwPhysicalMonitorArraySize, varptr(pPhysicalMonitorArray)) ; hMonitor : HMONITOR -> "intptr" ; dwPhysicalMonitorArraySize : DWORD -> "int" ; pPhysicalMonitorArray : PHYSICAL_MONITOR* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
dxva2 = windows.NewLazySystemDLL("dxva2.dll")
procGetPhysicalMonitorsFromHMONITOR = dxva2.NewProc("GetPhysicalMonitorsFromHMONITOR")
)
// hMonitor (HMONITOR), dwPhysicalMonitorArraySize (DWORD), pPhysicalMonitorArray (PHYSICAL_MONITOR* out)
r1, _, err := procGetPhysicalMonitorsFromHMONITOR.Call(
uintptr(hMonitor),
uintptr(dwPhysicalMonitorArraySize),
uintptr(pPhysicalMonitorArray),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction GetPhysicalMonitorsFromHMONITOR(
hMonitor: THandle; // HMONITOR
dwPhysicalMonitorArraySize: DWORD; // DWORD
pPhysicalMonitorArray: Pointer // PHYSICAL_MONITOR* out
): BOOL; stdcall;
external 'dxva2.dll' name 'GetPhysicalMonitorsFromHMONITOR';result := DllCall("dxva2\GetPhysicalMonitorsFromHMONITOR"
, "Ptr", hMonitor ; HMONITOR
, "UInt", dwPhysicalMonitorArraySize ; DWORD
, "Ptr", pPhysicalMonitorArray ; PHYSICAL_MONITOR* out
, "Int") ; return: BOOL●GetPhysicalMonitorsFromHMONITOR(hMonitor, dwPhysicalMonitorArraySize, pPhysicalMonitorArray) = DLL("dxva2.dll", "bool GetPhysicalMonitorsFromHMONITOR(void*, dword, void*)")
# 呼び出し: GetPhysicalMonitorsFromHMONITOR(hMonitor, dwPhysicalMonitorArraySize, pPhysicalMonitorArray)
# hMonitor : HMONITOR -> "void*"
# dwPhysicalMonitorArraySize : DWORD -> "dword"
# pPhysicalMonitorArray : PHYSICAL_MONITOR* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。