Win32 API 日本語リファレンス
ホームUI.ColorSystem › GetDeviceGammaRamp

GetDeviceGammaRamp

関数
ディスプレイデバイスのガンマランプを取得する。
DLLGDI32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

BOOL GetDeviceGammaRamp(
    HDC hdc,
    void* lpRamp
);

パラメーター

名前方向
hdcHDCin
lpRampvoid*out

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL GetDeviceGammaRamp(
    HDC hdc,
    void* lpRamp
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("GDI32.dll", ExactSpelling = true)]
static extern bool GetDeviceGammaRamp(
    IntPtr hdc,   // HDC
    IntPtr lpRamp   // void* out
);
<DllImport("GDI32.dll", ExactSpelling:=True)>
Public Shared Function GetDeviceGammaRamp(
    hdc As IntPtr,   ' HDC
    lpRamp As IntPtr   ' void* out
) As Boolean
End Function
' hdc : HDC
' lpRamp : void* out
Declare PtrSafe Function GetDeviceGammaRamp Lib "gdi32" ( _
    ByVal hdc As LongPtr, _
    ByVal lpRamp As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetDeviceGammaRamp = ctypes.windll.gdi32.GetDeviceGammaRamp
GetDeviceGammaRamp.restype = wintypes.BOOL
GetDeviceGammaRamp.argtypes = [
    wintypes.HANDLE,  # hdc : HDC
    ctypes.POINTER(None),  # lpRamp : void* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('GDI32.dll')
GetDeviceGammaRamp = Fiddle::Function.new(
  lib['GetDeviceGammaRamp'],
  [
    Fiddle::TYPE_VOIDP,  # hdc : HDC
    Fiddle::TYPE_VOIDP,  # lpRamp : void* out
  ],
  Fiddle::TYPE_INT)
#[link(name = "gdi32")]
extern "system" {
    fn GetDeviceGammaRamp(
        hdc: *mut core::ffi::c_void,  // HDC
        lpRamp: *mut ()  // void* out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("GDI32.dll")]
public static extern bool GetDeviceGammaRamp(IntPtr hdc, IntPtr lpRamp);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_GetDeviceGammaRamp' -Namespace Win32 -PassThru
# $api::GetDeviceGammaRamp(hdc, lpRamp)
#uselib "GDI32.dll"
#func global GetDeviceGammaRamp "GetDeviceGammaRamp" sptr, sptr
; GetDeviceGammaRamp hdc, lpRamp   ; 戻り値は stat
; hdc : HDC -> "sptr"
; lpRamp : void* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "GDI32.dll"
#cfunc global GetDeviceGammaRamp "GetDeviceGammaRamp" sptr, sptr
; res = GetDeviceGammaRamp(hdc, lpRamp)
; hdc : HDC -> "sptr"
; lpRamp : void* out -> "sptr"
; BOOL GetDeviceGammaRamp(HDC hdc, void* lpRamp)
#uselib "GDI32.dll"
#cfunc global GetDeviceGammaRamp "GetDeviceGammaRamp" intptr, intptr
; res = GetDeviceGammaRamp(hdc, lpRamp)
; hdc : HDC -> "intptr"
; lpRamp : void* out -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	gdi32 = windows.NewLazySystemDLL("GDI32.dll")
	procGetDeviceGammaRamp = gdi32.NewProc("GetDeviceGammaRamp")
)

// hdc (HDC), lpRamp (void* out)
r1, _, err := procGetDeviceGammaRamp.Call(
	uintptr(hdc),
	uintptr(lpRamp),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function GetDeviceGammaRamp(
  hdc: THandle;   // HDC
  lpRamp: Pointer   // void* out
): BOOL; stdcall;
  external 'GDI32.dll' name 'GetDeviceGammaRamp';
result := DllCall("GDI32\GetDeviceGammaRamp"
    , "Ptr", hdc   ; HDC
    , "Ptr", lpRamp   ; void* out
    , "Int")   ; return: BOOL
●GetDeviceGammaRamp(hdc, lpRamp) = DLL("GDI32.dll", "bool GetDeviceGammaRamp(void*, void*)")
# 呼び出し: GetDeviceGammaRamp(hdc, lpRamp)
# hdc : HDC -> "void*"
# lpRamp : void* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。