ホーム › System.SystemInformation › GetIntegratedDisplaySize
GetIntegratedDisplaySize
関数内蔵ディスプレイの対角サイズをインチ単位で取得する。
シグネチャ
// api-ms-win-core-sysinfo-l1-2-3.dll
#include <windows.h>
HRESULT GetIntegratedDisplaySize(
DOUBLE* sizeInInches
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| sizeInInches | DOUBLE* | out | 内蔵スクリーンの対角サイズ(インチ単位)の最良推定値。 |
戻り値の型: HRESULT
公式ドキュメント
内蔵スクリーンの対角サイズ(インチ単位)の最良推定値を取得します。
戻り値
関数が成功したか失敗したかを示す結果コード。
解説(Remarks)
ディスプレイサイズ情報の取得元としてディスプレイドライバーを使用します。スクリーンサイズに対するレジストリの上書きは使用されません。ディスプレイアダプターの接続タイプを使用して、どのディスプレイがシステムに内蔵されているか(内蔵ディスプレイが存在する場合)を判定します。内蔵ディスプレイが検出されない場合は、エラーが返されます。検出するには、ディスプレイがアクティブである必要があります。たとえば、この関数を呼び出す際にふたを閉じることはできません。
この関数を使用するアプリケーションをコンパイルする方法については、 Windows ヘッダーの使用を参照してください。
例
次の関数は、内蔵スクリーンの対角サイズ(インチ単位)の最良推定値を表示します。
void ShowIntegratedDisplaySize()
{
Platform::String^ buffer;
double sizeInInches;
HRESULT result = GetIntegratedDisplaySize(&sizeInInches) ;
if (SUCCEEDED(result))
{
buffer += "Internal display size is " + sizeInInches.ToString() + " inches.\n";
}
else
{
buffer += "No valid Internal display found. \n";
}
// Output the string buffer here...
}
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// api-ms-win-core-sysinfo-l1-2-3.dll
#include <windows.h>
HRESULT GetIntegratedDisplaySize(
DOUBLE* sizeInInches
);[DllImport("api-ms-win-core-sysinfo-l1-2-3.dll", ExactSpelling = true)]
static extern int GetIntegratedDisplaySize(
out double sizeInInches // DOUBLE* out
);<DllImport("api-ms-win-core-sysinfo-l1-2-3.dll", ExactSpelling:=True)>
Public Shared Function GetIntegratedDisplaySize(
<Out> ByRef sizeInInches As Double ' DOUBLE* out
) As Integer
End Function' sizeInInches : DOUBLE* out
Declare PtrSafe Function GetIntegratedDisplaySize Lib "api-ms-win-core-sysinfo-l1-2-3" ( _
ByRef sizeInInches As Double) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetIntegratedDisplaySize = ctypes.windll.LoadLibrary("api-ms-win-core-sysinfo-l1-2-3.dll").GetIntegratedDisplaySize
GetIntegratedDisplaySize.restype = ctypes.c_int
GetIntegratedDisplaySize.argtypes = [
ctypes.POINTER(ctypes.c_double), # sizeInInches : DOUBLE* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('api-ms-win-core-sysinfo-l1-2-3.dll')
GetIntegratedDisplaySize = Fiddle::Function.new(
lib['GetIntegratedDisplaySize'],
[
Fiddle::TYPE_VOIDP, # sizeInInches : DOUBLE* out
],
Fiddle::TYPE_INT)#[link(name = "api-ms-win-core-sysinfo-l1-2-3")]
extern "system" {
fn GetIntegratedDisplaySize(
sizeInInches: *mut f64 // DOUBLE* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("api-ms-win-core-sysinfo-l1-2-3.dll")]
public static extern int GetIntegratedDisplaySize(out double sizeInInches);
"@
$api = Add-Type -MemberDefinition $sig -Name 'api-ms-win-core-sysinfo-l1-2-3_GetIntegratedDisplaySize' -Namespace Win32 -PassThru
# $api::GetIntegratedDisplaySize(sizeInInches)#uselib "api-ms-win-core-sysinfo-l1-2-3.dll"
#func global GetIntegratedDisplaySize "GetIntegratedDisplaySize" sptr
; GetIntegratedDisplaySize varptr(sizeInInches) ; 戻り値は stat
; sizeInInches : DOUBLE* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "api-ms-win-core-sysinfo-l1-2-3.dll" #cfunc global GetIntegratedDisplaySize "GetIntegratedDisplaySize" var ; res = GetIntegratedDisplaySize(sizeInInches) ; sizeInInches : DOUBLE* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "api-ms-win-core-sysinfo-l1-2-3.dll" #cfunc global GetIntegratedDisplaySize "GetIntegratedDisplaySize" sptr ; res = GetIntegratedDisplaySize(varptr(sizeInInches)) ; sizeInInches : DOUBLE* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT GetIntegratedDisplaySize(DOUBLE* sizeInInches) #uselib "api-ms-win-core-sysinfo-l1-2-3.dll" #cfunc global GetIntegratedDisplaySize "GetIntegratedDisplaySize" var ; res = GetIntegratedDisplaySize(sizeInInches) ; sizeInInches : DOUBLE* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT GetIntegratedDisplaySize(DOUBLE* sizeInInches) #uselib "api-ms-win-core-sysinfo-l1-2-3.dll" #cfunc global GetIntegratedDisplaySize "GetIntegratedDisplaySize" intptr ; res = GetIntegratedDisplaySize(varptr(sizeInInches)) ; sizeInInches : DOUBLE* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
api_ms_win_core_sysinfo_l1_2_3 = windows.NewLazySystemDLL("api-ms-win-core-sysinfo-l1-2-3.dll")
procGetIntegratedDisplaySize = api_ms_win_core_sysinfo_l1_2_3.NewProc("GetIntegratedDisplaySize")
)
// sizeInInches (DOUBLE* out)
r1, _, err := procGetIntegratedDisplaySize.Call(
uintptr(sizeInInches),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction GetIntegratedDisplaySize(
sizeInInches: Pointer // DOUBLE* out
): Integer; stdcall;
external 'api-ms-win-core-sysinfo-l1-2-3.dll' name 'GetIntegratedDisplaySize';result := DllCall("api-ms-win-core-sysinfo-l1-2-3\GetIntegratedDisplaySize"
, "Ptr", sizeInInches ; DOUBLE* out
, "Int") ; return: HRESULT●GetIntegratedDisplaySize(sizeInInches) = DLL("api-ms-win-core-sysinfo-l1-2-3.dll", "int GetIntegratedDisplaySize(void*)")
# 呼び出し: GetIntegratedDisplaySize(sizeInInches)
# sizeInInches : DOUBLE* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "api-ms-win-core-sysinfo-l1-2-3" fn GetIntegratedDisplaySize(
sizeInInches: [*c]f64 // DOUBLE* out
) callconv(std.os.windows.WINAPI) i32;proc GetIntegratedDisplaySize(
sizeInInches: ptr float64 # DOUBLE* out
): int32 {.importc: "GetIntegratedDisplaySize", stdcall, dynlib: "api-ms-win-core-sysinfo-l1-2-3.dll".}pragma(lib, "api-ms-win-core-sysinfo-l1-2-3");
extern(Windows)
int GetIntegratedDisplaySize(
double* sizeInInches // DOUBLE* out
);ccall((:GetIntegratedDisplaySize, "api-ms-win-core-sysinfo-l1-2-3.dll"), stdcall, Int32,
(Ptr{Float64},),
sizeInInches)
# sizeInInches : DOUBLE* out -> Ptr{Float64}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t GetIntegratedDisplaySize(
double* sizeInInches);
]]
local api-ms-win-core-sysinfo-l1-2-3 = ffi.load("api-ms-win-core-sysinfo-l1-2-3")
-- api-ms-win-core-sysinfo-l1-2-3.GetIntegratedDisplaySize(sizeInInches)
-- sizeInInches : DOUBLE* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('api-ms-win-core-sysinfo-l1-2-3.dll');
const GetIntegratedDisplaySize = lib.func('__stdcall', 'GetIntegratedDisplaySize', 'int32_t', ['double *']);
// GetIntegratedDisplaySize(sizeInInches)
// sizeInInches : DOUBLE* out -> 'double *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("api-ms-win-core-sysinfo-l1-2-3.dll", {
GetIntegratedDisplaySize: { parameters: ["pointer"], result: "i32" },
});
// lib.symbols.GetIntegratedDisplaySize(sizeInInches)
// sizeInInches : DOUBLE* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t GetIntegratedDisplaySize(
double* sizeInInches);
C, "api-ms-win-core-sysinfo-l1-2-3.dll");
// $ffi->GetIntegratedDisplaySize(sizeInInches);
// sizeInInches : DOUBLE* 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 Api-ms-win-core-sysinfo-l1-2-3 extends StdCallLibrary {
Api-ms-win-core-sysinfo-l1-2-3 INSTANCE = Native.load("api-ms-win-core-sysinfo-l1-2-3", Api-ms-win-core-sysinfo-l1-2-3.class);
int GetIntegratedDisplaySize(
DoubleByReference sizeInInches // DOUBLE* out
);
}@[Link("api-ms-win-core-sysinfo-l1-2-3")]
lib Libapi-ms-win-core-sysinfo-l1-2-3
fun GetIntegratedDisplaySize = GetIntegratedDisplaySize(
sizeInInches : Float64* # DOUBLE* out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef GetIntegratedDisplaySizeNative = Int32 Function(Pointer<Double>);
typedef GetIntegratedDisplaySizeDart = int Function(Pointer<Double>);
final GetIntegratedDisplaySize = DynamicLibrary.open('api-ms-win-core-sysinfo-l1-2-3.dll')
.lookupFunction<GetIntegratedDisplaySizeNative, GetIntegratedDisplaySizeDart>('GetIntegratedDisplaySize');
// sizeInInches : DOUBLE* out -> Pointer<Double>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function GetIntegratedDisplaySize(
sizeInInches: Pointer // DOUBLE* out
): Integer; stdcall;
external 'api-ms-win-core-sysinfo-l1-2-3.dll' name 'GetIntegratedDisplaySize';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "GetIntegratedDisplaySize"
c_GetIntegratedDisplaySize :: Ptr CDouble -> IO Int32
-- sizeInInches : DOUBLE* out -> Ptr CDouble
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let getintegrateddisplaysize =
foreign "GetIntegratedDisplaySize"
((ptr double) @-> returning int32_t)
(* sizeInInches : DOUBLE* out -> (ptr double) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library api-ms-win-core-sysinfo-l1-2-3 (t "api-ms-win-core-sysinfo-l1-2-3.dll"))
(cffi:use-foreign-library api-ms-win-core-sysinfo-l1-2-3)
(cffi:defcfun ("GetIntegratedDisplaySize" get-integrated-display-size :convention :stdcall) :int32
(size-in-inches :pointer)) ; DOUBLE* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $GetIntegratedDisplaySize = Win32::API::More->new('api-ms-win-core-sysinfo-l1-2-3',
'int GetIntegratedDisplaySize(LPVOID sizeInInches)');
# my $ret = $GetIntegratedDisplaySize->Call($sizeInInches);
# sizeInInches : DOUBLE* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。