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

SetMonitorContrast

関数
モニタのコントラストを新しい値に設定する。
DLLdxva2.dll呼出規約winapiSetLastErrorあり対応OSWindows Vista 以降

シグネチャ

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

INT SetMonitorContrast(
    HANDLE hMonitor,
    DWORD dwNewContrast
);

パラメーター

名前方向
hMonitorHANDLEin
dwNewContrastDWORDin

戻り値の型: INT

各言語での呼び出し定義

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

INT SetMonitorContrast(
    HANDLE hMonitor,
    DWORD dwNewContrast
);
[DllImport("dxva2.dll", SetLastError = true, ExactSpelling = true)]
static extern int SetMonitorContrast(
    IntPtr hMonitor,   // HANDLE
    uint dwNewContrast   // DWORD
);
<DllImport("dxva2.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetMonitorContrast(
    hMonitor As IntPtr,   ' HANDLE
    dwNewContrast As UInteger   ' DWORD
) As Integer
End Function
' hMonitor : HANDLE
' dwNewContrast : DWORD
Declare PtrSafe Function SetMonitorContrast Lib "dxva2" ( _
    ByVal hMonitor As LongPtr, _
    ByVal dwNewContrast As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SetMonitorContrast = ctypes.windll.dxva2.SetMonitorContrast
SetMonitorContrast.restype = ctypes.c_int
SetMonitorContrast.argtypes = [
    wintypes.HANDLE,  # hMonitor : HANDLE
    wintypes.DWORD,  # dwNewContrast : DWORD
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('dxva2.dll')
SetMonitorContrast = Fiddle::Function.new(
  lib['SetMonitorContrast'],
  [
    Fiddle::TYPE_VOIDP,  # hMonitor : HANDLE
    -Fiddle::TYPE_INT,  # dwNewContrast : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "dxva2")]
extern "system" {
    fn SetMonitorContrast(
        hMonitor: *mut core::ffi::c_void,  // HANDLE
        dwNewContrast: u32  // DWORD
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("dxva2.dll", SetLastError = true)]
public static extern int SetMonitorContrast(IntPtr hMonitor, uint dwNewContrast);
"@
$api = Add-Type -MemberDefinition $sig -Name 'dxva2_SetMonitorContrast' -Namespace Win32 -PassThru
# $api::SetMonitorContrast(hMonitor, dwNewContrast)
#uselib "dxva2.dll"
#func global SetMonitorContrast "SetMonitorContrast" sptr, sptr
; SetMonitorContrast hMonitor, dwNewContrast   ; 戻り値は stat
; hMonitor : HANDLE -> "sptr"
; dwNewContrast : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "dxva2.dll"
#cfunc global SetMonitorContrast "SetMonitorContrast" sptr, int
; res = SetMonitorContrast(hMonitor, dwNewContrast)
; hMonitor : HANDLE -> "sptr"
; dwNewContrast : DWORD -> "int"
; INT SetMonitorContrast(HANDLE hMonitor, DWORD dwNewContrast)
#uselib "dxva2.dll"
#cfunc global SetMonitorContrast "SetMonitorContrast" intptr, int
; res = SetMonitorContrast(hMonitor, dwNewContrast)
; hMonitor : HANDLE -> "intptr"
; dwNewContrast : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	dxva2 = windows.NewLazySystemDLL("dxva2.dll")
	procSetMonitorContrast = dxva2.NewProc("SetMonitorContrast")
)

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