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

GetColorProfileFromHandle

関数
プロファイルハンドルからプロファイルデータを取得する。
DLLmscms.dll呼出規約winapi

シグネチャ

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

BOOL GetColorProfileFromHandle(
    INT_PTR hProfile,
    BYTE* pProfile,   // optional
    DWORD* pcbProfile
);

パラメーター

名前方向
hProfileINT_PTRin
pProfileBYTE*outoptional
pcbProfileDWORD*inout

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL GetColorProfileFromHandle(
    INT_PTR hProfile,
    BYTE* pProfile,   // optional
    DWORD* pcbProfile
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("mscms.dll", ExactSpelling = true)]
static extern bool GetColorProfileFromHandle(
    IntPtr hProfile,   // INT_PTR
    IntPtr pProfile,   // BYTE* optional, out
    ref uint pcbProfile   // DWORD* in/out
);
<DllImport("mscms.dll", ExactSpelling:=True)>
Public Shared Function GetColorProfileFromHandle(
    hProfile As IntPtr,   ' INT_PTR
    pProfile As IntPtr,   ' BYTE* optional, out
    ByRef pcbProfile As UInteger   ' DWORD* in/out
) As Boolean
End Function
' hProfile : INT_PTR
' pProfile : BYTE* optional, out
' pcbProfile : DWORD* in/out
Declare PtrSafe Function GetColorProfileFromHandle Lib "mscms" ( _
    ByVal hProfile As LongPtr, _
    ByVal pProfile As LongPtr, _
    ByRef pcbProfile As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetColorProfileFromHandle = ctypes.windll.mscms.GetColorProfileFromHandle
GetColorProfileFromHandle.restype = wintypes.BOOL
GetColorProfileFromHandle.argtypes = [
    ctypes.c_ssize_t,  # hProfile : INT_PTR
    ctypes.POINTER(ctypes.c_ubyte),  # pProfile : BYTE* optional, out
    ctypes.POINTER(wintypes.DWORD),  # pcbProfile : DWORD* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('mscms.dll')
GetColorProfileFromHandle = Fiddle::Function.new(
  lib['GetColorProfileFromHandle'],
  [
    Fiddle::TYPE_INTPTR_T,  # hProfile : INT_PTR
    Fiddle::TYPE_VOIDP,  # pProfile : BYTE* optional, out
    Fiddle::TYPE_VOIDP,  # pcbProfile : DWORD* in/out
  ],
  Fiddle::TYPE_INT)
#[link(name = "mscms")]
extern "system" {
    fn GetColorProfileFromHandle(
        hProfile: isize,  // INT_PTR
        pProfile: *mut u8,  // BYTE* optional, out
        pcbProfile: *mut u32  // DWORD* in/out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("mscms.dll")]
public static extern bool GetColorProfileFromHandle(IntPtr hProfile, IntPtr pProfile, ref uint pcbProfile);
"@
$api = Add-Type -MemberDefinition $sig -Name 'mscms_GetColorProfileFromHandle' -Namespace Win32 -PassThru
# $api::GetColorProfileFromHandle(hProfile, pProfile, pcbProfile)
#uselib "mscms.dll"
#func global GetColorProfileFromHandle "GetColorProfileFromHandle" sptr, sptr, sptr
; GetColorProfileFromHandle hProfile, varptr(pProfile), varptr(pcbProfile)   ; 戻り値は stat
; hProfile : INT_PTR -> "sptr"
; pProfile : BYTE* optional, out -> "sptr"
; pcbProfile : DWORD* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "mscms.dll"
#cfunc global GetColorProfileFromHandle "GetColorProfileFromHandle" sptr, var, var
; res = GetColorProfileFromHandle(hProfile, pProfile, pcbProfile)
; hProfile : INT_PTR -> "sptr"
; pProfile : BYTE* optional, out -> "var"
; pcbProfile : DWORD* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL GetColorProfileFromHandle(INT_PTR hProfile, BYTE* pProfile, DWORD* pcbProfile)
#uselib "mscms.dll"
#cfunc global GetColorProfileFromHandle "GetColorProfileFromHandle" intptr, var, var
; res = GetColorProfileFromHandle(hProfile, pProfile, pcbProfile)
; hProfile : INT_PTR -> "intptr"
; pProfile : BYTE* optional, out -> "var"
; pcbProfile : DWORD* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	mscms = windows.NewLazySystemDLL("mscms.dll")
	procGetColorProfileFromHandle = mscms.NewProc("GetColorProfileFromHandle")
)

// hProfile (INT_PTR), pProfile (BYTE* optional, out), pcbProfile (DWORD* in/out)
r1, _, err := procGetColorProfileFromHandle.Call(
	uintptr(hProfile),
	uintptr(pProfile),
	uintptr(pcbProfile),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function GetColorProfileFromHandle(
  hProfile: NativeInt;   // INT_PTR
  pProfile: Pointer;   // BYTE* optional, out
  pcbProfile: Pointer   // DWORD* in/out
): BOOL; stdcall;
  external 'mscms.dll' name 'GetColorProfileFromHandle';
result := DllCall("mscms\GetColorProfileFromHandle"
    , "Ptr", hProfile   ; INT_PTR
    , "Ptr", pProfile   ; BYTE* optional, out
    , "Ptr", pcbProfile   ; DWORD* in/out
    , "Int")   ; return: BOOL
●GetColorProfileFromHandle(hProfile, pProfile, pcbProfile) = DLL("mscms.dll", "bool GetColorProfileFromHandle(int, void*, void*)")
# 呼び出し: GetColorProfileFromHandle(hProfile, pProfile, pcbProfile)
# hProfile : INT_PTR -> "int"
# pProfile : BYTE* optional, out -> "void*"
# pcbProfile : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。