ホーム › UI.WindowsAndMessaging › GetSystemMetrics
GetSystemMetrics
関数画面寸法やシステム構成要素の各種メトリクス値を取得する。
シグネチャ
// USER32.dll
#include <windows.h>
INT GetSystemMetrics(
SYSTEM_METRICS_INDEX nIndex
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| nIndex | SYSTEM_METRICS_INDEX | in |
戻り値の型: INT
各言語での呼び出し定義
// USER32.dll
#include <windows.h>
INT GetSystemMetrics(
SYSTEM_METRICS_INDEX nIndex
);[DllImport("USER32.dll", ExactSpelling = true)]
static extern int GetSystemMetrics(
int nIndex // SYSTEM_METRICS_INDEX
);<DllImport("USER32.dll", ExactSpelling:=True)>
Public Shared Function GetSystemMetrics(
nIndex As Integer ' SYSTEM_METRICS_INDEX
) As Integer
End Function' nIndex : SYSTEM_METRICS_INDEX
Declare PtrSafe Function GetSystemMetrics Lib "user32" ( _
ByVal nIndex As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetSystemMetrics = ctypes.windll.user32.GetSystemMetrics
GetSystemMetrics.restype = ctypes.c_int
GetSystemMetrics.argtypes = [
ctypes.c_int, # nIndex : SYSTEM_METRICS_INDEX
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('USER32.dll')
GetSystemMetrics = Fiddle::Function.new(
lib['GetSystemMetrics'],
[
Fiddle::TYPE_INT, # nIndex : SYSTEM_METRICS_INDEX
],
Fiddle::TYPE_INT)#[link(name = "user32")]
extern "system" {
fn GetSystemMetrics(
nIndex: i32 // SYSTEM_METRICS_INDEX
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("USER32.dll")]
public static extern int GetSystemMetrics(int nIndex);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_GetSystemMetrics' -Namespace Win32 -PassThru
# $api::GetSystemMetrics(nIndex)#uselib "USER32.dll"
#func global GetSystemMetrics "GetSystemMetrics" sptr
; GetSystemMetrics nIndex ; 戻り値は stat
; nIndex : SYSTEM_METRICS_INDEX -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "USER32.dll"
#cfunc global GetSystemMetrics "GetSystemMetrics" int
; res = GetSystemMetrics(nIndex)
; nIndex : SYSTEM_METRICS_INDEX -> "int"; INT GetSystemMetrics(SYSTEM_METRICS_INDEX nIndex)
#uselib "USER32.dll"
#cfunc global GetSystemMetrics "GetSystemMetrics" int
; res = GetSystemMetrics(nIndex)
; nIndex : SYSTEM_METRICS_INDEX -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
user32 = windows.NewLazySystemDLL("USER32.dll")
procGetSystemMetrics = user32.NewProc("GetSystemMetrics")
)
// nIndex (SYSTEM_METRICS_INDEX)
r1, _, err := procGetSystemMetrics.Call(
uintptr(nIndex),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction GetSystemMetrics(
nIndex: Integer // SYSTEM_METRICS_INDEX
): Integer; stdcall;
external 'USER32.dll' name 'GetSystemMetrics';result := DllCall("USER32\GetSystemMetrics"
, "Int", nIndex ; SYSTEM_METRICS_INDEX
, "Int") ; return: INT●GetSystemMetrics(nIndex) = DLL("USER32.dll", "int GetSystemMetrics(int)")
# 呼び出し: GetSystemMetrics(nIndex)
# nIndex : SYSTEM_METRICS_INDEX -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。