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

GetPhysicalMonitorsFromIDirect3DDevice9

関数
Direct3D9デバイスから物理モニタのハンドル配列を取得する。
DLLdxva2.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

HRESULT GetPhysicalMonitorsFromIDirect3DDevice9(
    IDirect3DDevice9* pDirect3DDevice9,
    DWORD dwPhysicalMonitorArraySize,
    PHYSICAL_MONITOR* pPhysicalMonitorArray
);

パラメーター

名前方向説明
pDirect3DDevice9IDirect3DDevice9*inDirect3D デバイスの IDirect3DDevice9 インターフェイスへのポインターです。
dwPhysicalMonitorArraySizeDWORDinpPhysicalMonitorArray の要素数です。配列に必要なサイズを取得するには、GetNumberOfPhysicalMonitorsFromIDirect3DDevice9 を呼び出してください。
pPhysicalMonitorArrayPHYSICAL_MONITOR*outPHYSICAL_MONITOR 構造体の配列へのポインターです。配列は呼び出し元が割り当てる必要があります。

戻り値の型: HRESULT

公式ドキュメント

Direct3D デバイスに関連付けられた物理モニターを取得します。

戻り値

この関数が成功すると、S_OK を返します。それ以外の場合は HRESULT エラーコードを返します。

解説(Remarks)

1 つの Direct3D デバイスは、複数の物理モニターに関連付けられる場合があります。この関数は、各物理モニターのハンドルとテキストによる説明を返します。

モニターハンドルの使用が終わったら、pPhysicalMonitorArray 配列を DestroyPhysicalMonitors 関数に渡してハンドルを閉じてください。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

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

HRESULT GetPhysicalMonitorsFromIDirect3DDevice9(
    IDirect3DDevice9* pDirect3DDevice9,
    DWORD dwPhysicalMonitorArraySize,
    PHYSICAL_MONITOR* pPhysicalMonitorArray
);
[DllImport("dxva2.dll", ExactSpelling = true)]
static extern int GetPhysicalMonitorsFromIDirect3DDevice9(
    IntPtr pDirect3DDevice9,   // IDirect3DDevice9*
    uint dwPhysicalMonitorArraySize,   // DWORD
    IntPtr pPhysicalMonitorArray   // PHYSICAL_MONITOR* out
);
<DllImport("dxva2.dll", ExactSpelling:=True)>
Public Shared Function GetPhysicalMonitorsFromIDirect3DDevice9(
    pDirect3DDevice9 As IntPtr,   ' IDirect3DDevice9*
    dwPhysicalMonitorArraySize As UInteger,   ' DWORD
    pPhysicalMonitorArray As IntPtr   ' PHYSICAL_MONITOR* out
) As Integer
End Function
' pDirect3DDevice9 : IDirect3DDevice9*
' dwPhysicalMonitorArraySize : DWORD
' pPhysicalMonitorArray : PHYSICAL_MONITOR* out
Declare PtrSafe Function GetPhysicalMonitorsFromIDirect3DDevice9 Lib "dxva2" ( _
    ByVal pDirect3DDevice9 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

GetPhysicalMonitorsFromIDirect3DDevice9 = ctypes.windll.dxva2.GetPhysicalMonitorsFromIDirect3DDevice9
GetPhysicalMonitorsFromIDirect3DDevice9.restype = ctypes.c_int
GetPhysicalMonitorsFromIDirect3DDevice9.argtypes = [
    ctypes.c_void_p,  # pDirect3DDevice9 : IDirect3DDevice9*
    wintypes.DWORD,  # dwPhysicalMonitorArraySize : DWORD
    ctypes.c_void_p,  # pPhysicalMonitorArray : PHYSICAL_MONITOR* out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	dxva2 = windows.NewLazySystemDLL("dxva2.dll")
	procGetPhysicalMonitorsFromIDirect3DDevice9 = dxva2.NewProc("GetPhysicalMonitorsFromIDirect3DDevice9")
)

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

extern "dxva2" fn GetPhysicalMonitorsFromIDirect3DDevice9(
    pDirect3DDevice9: ?*anyopaque, // IDirect3DDevice9*
    dwPhysicalMonitorArraySize: u32, // DWORD
    pPhysicalMonitorArray: [*c]PHYSICAL_MONITOR // PHYSICAL_MONITOR* out
) callconv(std.os.windows.WINAPI) i32;
proc GetPhysicalMonitorsFromIDirect3DDevice9(
    pDirect3DDevice9: pointer,  # IDirect3DDevice9*
    dwPhysicalMonitorArraySize: uint32,  # DWORD
    pPhysicalMonitorArray: ptr PHYSICAL_MONITOR  # PHYSICAL_MONITOR* out
): int32 {.importc: "GetPhysicalMonitorsFromIDirect3DDevice9", stdcall, dynlib: "dxva2.dll".}
pragma(lib, "dxva2");
extern(Windows)
int GetPhysicalMonitorsFromIDirect3DDevice9(
    void* pDirect3DDevice9,   // IDirect3DDevice9*
    uint dwPhysicalMonitorArraySize,   // DWORD
    PHYSICAL_MONITOR* pPhysicalMonitorArray   // PHYSICAL_MONITOR* out
);
ccall((:GetPhysicalMonitorsFromIDirect3DDevice9, "dxva2.dll"), stdcall, Int32,
      (Ptr{Cvoid}, UInt32, Ptr{PHYSICAL_MONITOR}),
      pDirect3DDevice9, dwPhysicalMonitorArraySize, pPhysicalMonitorArray)
# pDirect3DDevice9 : IDirect3DDevice9* -> Ptr{Cvoid}
# dwPhysicalMonitorArraySize : DWORD -> UInt32
# pPhysicalMonitorArray : PHYSICAL_MONITOR* out -> Ptr{PHYSICAL_MONITOR}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t GetPhysicalMonitorsFromIDirect3DDevice9(
    void* pDirect3DDevice9,
    uint32_t dwPhysicalMonitorArraySize,
    void* pPhysicalMonitorArray);
]]
local dxva2 = ffi.load("dxva2")
-- dxva2.GetPhysicalMonitorsFromIDirect3DDevice9(pDirect3DDevice9, dwPhysicalMonitorArraySize, pPhysicalMonitorArray)
-- pDirect3DDevice9 : IDirect3DDevice9*
-- dwPhysicalMonitorArraySize : DWORD
-- pPhysicalMonitorArray : PHYSICAL_MONITOR* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('dxva2.dll');
const GetPhysicalMonitorsFromIDirect3DDevice9 = lib.func('__stdcall', 'GetPhysicalMonitorsFromIDirect3DDevice9', 'int32_t', ['void *', 'uint32_t', 'void *']);
// GetPhysicalMonitorsFromIDirect3DDevice9(pDirect3DDevice9, dwPhysicalMonitorArraySize, pPhysicalMonitorArray)
// pDirect3DDevice9 : IDirect3DDevice9* -> 'void *'
// dwPhysicalMonitorArraySize : DWORD -> 'uint32_t'
// pPhysicalMonitorArray : PHYSICAL_MONITOR* out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("dxva2.dll", {
  GetPhysicalMonitorsFromIDirect3DDevice9: { parameters: ["pointer", "u32", "pointer"], result: "i32" },
});
// lib.symbols.GetPhysicalMonitorsFromIDirect3DDevice9(pDirect3DDevice9, dwPhysicalMonitorArraySize, pPhysicalMonitorArray)
// pDirect3DDevice9 : IDirect3DDevice9* -> "pointer"
// dwPhysicalMonitorArraySize : DWORD -> "u32"
// pPhysicalMonitorArray : PHYSICAL_MONITOR* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t GetPhysicalMonitorsFromIDirect3DDevice9(
    void* pDirect3DDevice9,
    uint32_t dwPhysicalMonitorArraySize,
    void* pPhysicalMonitorArray);
C, "dxva2.dll");
// $ffi->GetPhysicalMonitorsFromIDirect3DDevice9(pDirect3DDevice9, dwPhysicalMonitorArraySize, pPhysicalMonitorArray);
// pDirect3DDevice9 : IDirect3DDevice9*
// dwPhysicalMonitorArraySize : DWORD
// pPhysicalMonitorArray : PHYSICAL_MONITOR* out
// 構造体/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 Dxva2 extends StdCallLibrary {
    Dxva2 INSTANCE = Native.load("dxva2", Dxva2.class);
    int GetPhysicalMonitorsFromIDirect3DDevice9(
        Pointer pDirect3DDevice9,   // IDirect3DDevice9*
        int dwPhysicalMonitorArraySize,   // DWORD
        Pointer pPhysicalMonitorArray   // PHYSICAL_MONITOR* out
    );
}
@[Link("dxva2")]
lib Libdxva2
  fun GetPhysicalMonitorsFromIDirect3DDevice9 = GetPhysicalMonitorsFromIDirect3DDevice9(
    pDirect3DDevice9 : Void*,   # IDirect3DDevice9*
    dwPhysicalMonitorArraySize : UInt32,   # DWORD
    pPhysicalMonitorArray : PHYSICAL_MONITOR*   # PHYSICAL_MONITOR* out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef GetPhysicalMonitorsFromIDirect3DDevice9Native = Int32 Function(Pointer<Void>, Uint32, Pointer<Void>);
typedef GetPhysicalMonitorsFromIDirect3DDevice9Dart = int Function(Pointer<Void>, int, Pointer<Void>);
final GetPhysicalMonitorsFromIDirect3DDevice9 = DynamicLibrary.open('dxva2.dll')
    .lookupFunction<GetPhysicalMonitorsFromIDirect3DDevice9Native, GetPhysicalMonitorsFromIDirect3DDevice9Dart>('GetPhysicalMonitorsFromIDirect3DDevice9');
// pDirect3DDevice9 : IDirect3DDevice9* -> Pointer<Void>
// dwPhysicalMonitorArraySize : DWORD -> Uint32
// pPhysicalMonitorArray : PHYSICAL_MONITOR* out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function GetPhysicalMonitorsFromIDirect3DDevice9(
  pDirect3DDevice9: Pointer;   // IDirect3DDevice9*
  dwPhysicalMonitorArraySize: DWORD;   // DWORD
  pPhysicalMonitorArray: Pointer   // PHYSICAL_MONITOR* out
): Integer; stdcall;
  external 'dxva2.dll' name 'GetPhysicalMonitorsFromIDirect3DDevice9';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "GetPhysicalMonitorsFromIDirect3DDevice9"
  c_GetPhysicalMonitorsFromIDirect3DDevice9 :: Ptr () -> Word32 -> Ptr () -> IO Int32
-- pDirect3DDevice9 : IDirect3DDevice9* -> Ptr ()
-- dwPhysicalMonitorArraySize : DWORD -> Word32
-- pPhysicalMonitorArray : PHYSICAL_MONITOR* out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let getphysicalmonitorsfromidirect3ddevice9 =
  foreign "GetPhysicalMonitorsFromIDirect3DDevice9"
    ((ptr void) @-> uint32_t @-> (ptr void) @-> returning int32_t)
(* pDirect3DDevice9 : IDirect3DDevice9* -> (ptr void) *)
(* dwPhysicalMonitorArraySize : DWORD -> uint32_t *)
(* pPhysicalMonitorArray : PHYSICAL_MONITOR* out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library dxva2 (t "dxva2.dll"))
(cffi:use-foreign-library dxva2)

(cffi:defcfun ("GetPhysicalMonitorsFromIDirect3DDevice9" get-physical-monitors-from-idirect3-ddevice9 :convention :stdcall) :int32
  (p-direct3-ddevice9 :pointer)   ; IDirect3DDevice9*
  (dw-physical-monitor-array-size :uint32)   ; DWORD
  (p-physical-monitor-array :pointer))   ; PHYSICAL_MONITOR* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $GetPhysicalMonitorsFromIDirect3DDevice9 = Win32::API::More->new('dxva2',
    'int GetPhysicalMonitorsFromIDirect3DDevice9(LPVOID pDirect3DDevice9, DWORD dwPhysicalMonitorArraySize, LPVOID pPhysicalMonitorArray)');
# my $ret = $GetPhysicalMonitorsFromIDirect3DDevice9->Call($pDirect3DDevice9, $dwPhysicalMonitorArraySize, $pPhysicalMonitorArray);
# pDirect3DDevice9 : IDirect3DDevice9* -> LPVOID
# dwPhysicalMonitorArraySize : DWORD -> DWORD
# pPhysicalMonitorArray : PHYSICAL_MONITOR* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型