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

GetColorProfileElement

関数
プロファイルから指定タグの要素データを取得する。
DLLmscms.dll呼出規約winapi

シグネチャ

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

BOOL GetColorProfileElement(
    INT_PTR hProfile,
    DWORD tag,
    DWORD dwOffset,
    DWORD* pcbElement,
    void* pElement,   // optional
    BOOL* pbReference
);

パラメーター

名前方向説明
hProfileINT_PTRin要素データを取得する対象のカラープロファイルハンドル。
tagDWORDin取得対象の要素を識別するタグのシグネチャ値。
dwOffsetDWORDin要素データ内の読み取り開始バイトオフセット。
pcbElementDWORD*inout入出力としてバッファのバイトサイズを受け渡すポインタ。必要サイズが返る。
pElementvoid*outoptional要素データを受け取るバッファ。NULLでサイズ問い合わせが可能。
pbReferenceBOOL*out他タグと共有参照される要素かを示すBOOL値へのポインタ。

戻り値の型: BOOL

各言語での呼び出し定義

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

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

GetColorProfileElement = ctypes.windll.mscms.GetColorProfileElement
GetColorProfileElement.restype = wintypes.BOOL
GetColorProfileElement.argtypes = [
    ctypes.c_ssize_t,  # hProfile : INT_PTR
    wintypes.DWORD,  # tag : DWORD
    wintypes.DWORD,  # dwOffset : DWORD
    ctypes.POINTER(wintypes.DWORD),  # pcbElement : DWORD* in/out
    ctypes.POINTER(None),  # pElement : void* optional, out
    ctypes.c_void_p,  # pbReference : BOOL* out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	mscms = windows.NewLazySystemDLL("mscms.dll")
	procGetColorProfileElement = mscms.NewProc("GetColorProfileElement")
)

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

extern "mscms" fn GetColorProfileElement(
    hProfile: isize, // INT_PTR
    tag: u32, // DWORD
    dwOffset: u32, // DWORD
    pcbElement: [*c]u32, // DWORD* in/out
    pElement: ?*anyopaque, // void* optional, out
    pbReference: [*c]i32 // BOOL* out
) callconv(std.os.windows.WINAPI) i32;
proc GetColorProfileElement(
    hProfile: int,  # INT_PTR
    tag: uint32,  # DWORD
    dwOffset: uint32,  # DWORD
    pcbElement: ptr uint32,  # DWORD* in/out
    pElement: pointer,  # void* optional, out
    pbReference: ptr int32  # BOOL* out
): int32 {.importc: "GetColorProfileElement", stdcall, dynlib: "mscms.dll".}
pragma(lib, "mscms");
extern(Windows)
int GetColorProfileElement(
    ptrdiff_t hProfile,   // INT_PTR
    uint tag,   // DWORD
    uint dwOffset,   // DWORD
    uint* pcbElement,   // DWORD* in/out
    void* pElement,   // void* optional, out
    int* pbReference   // BOOL* out
);
ccall((:GetColorProfileElement, "mscms.dll"), stdcall, Int32,
      (Int, UInt32, UInt32, Ptr{UInt32}, Ptr{Cvoid}, Ptr{Int32}),
      hProfile, tag, dwOffset, pcbElement, pElement, pbReference)
# hProfile : INT_PTR -> Int
# tag : DWORD -> UInt32
# dwOffset : DWORD -> UInt32
# pcbElement : DWORD* in/out -> Ptr{UInt32}
# pElement : void* optional, out -> Ptr{Cvoid}
# pbReference : BOOL* out -> Ptr{Int32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t GetColorProfileElement(
    intptr_t hProfile,
    uint32_t tag,
    uint32_t dwOffset,
    uint32_t* pcbElement,
    void* pElement,
    int32_t* pbReference);
]]
local mscms = ffi.load("mscms")
-- mscms.GetColorProfileElement(hProfile, tag, dwOffset, pcbElement, pElement, pbReference)
-- hProfile : INT_PTR
-- tag : DWORD
-- dwOffset : DWORD
-- pcbElement : DWORD* in/out
-- pElement : void* optional, out
-- pbReference : BOOL* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('mscms.dll');
const GetColorProfileElement = lib.func('__stdcall', 'GetColorProfileElement', 'int32_t', ['intptr_t', 'uint32_t', 'uint32_t', 'uint32_t *', 'void *', 'int32_t *']);
// GetColorProfileElement(hProfile, tag, dwOffset, pcbElement, pElement, pbReference)
// hProfile : INT_PTR -> 'intptr_t'
// tag : DWORD -> 'uint32_t'
// dwOffset : DWORD -> 'uint32_t'
// pcbElement : DWORD* in/out -> 'uint32_t *'
// pElement : void* optional, out -> 'void *'
// pbReference : BOOL* out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("mscms.dll", {
  GetColorProfileElement: { parameters: ["isize", "u32", "u32", "pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.GetColorProfileElement(hProfile, tag, dwOffset, pcbElement, pElement, pbReference)
// hProfile : INT_PTR -> "isize"
// tag : DWORD -> "u32"
// dwOffset : DWORD -> "u32"
// pcbElement : DWORD* in/out -> "pointer"
// pElement : void* optional, out -> "pointer"
// pbReference : BOOL* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t GetColorProfileElement(
    intptr_t hProfile,
    uint32_t tag,
    uint32_t dwOffset,
    uint32_t* pcbElement,
    void* pElement,
    int32_t* pbReference);
C, "mscms.dll");
// $ffi->GetColorProfileElement(hProfile, tag, dwOffset, pcbElement, pElement, pbReference);
// hProfile : INT_PTR
// tag : DWORD
// dwOffset : DWORD
// pcbElement : DWORD* in/out
// pElement : void* optional, out
// pbReference : BOOL* 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 Mscms extends StdCallLibrary {
    Mscms INSTANCE = Native.load("mscms", Mscms.class);
    boolean GetColorProfileElement(
        long hProfile,   // INT_PTR
        int tag,   // DWORD
        int dwOffset,   // DWORD
        IntByReference pcbElement,   // DWORD* in/out
        Pointer pElement,   // void* optional, out
        IntByReference pbReference   // BOOL* out
    );
}
@[Link("mscms")]
lib Libmscms
  fun GetColorProfileElement = GetColorProfileElement(
    hProfile : LibC::SSizeT,   # INT_PTR
    tag : UInt32,   # DWORD
    dwOffset : UInt32,   # DWORD
    pcbElement : UInt32*,   # DWORD* in/out
    pElement : Void*,   # void* optional, out
    pbReference : Int32*   # BOOL* out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef GetColorProfileElementNative = Int32 Function(IntPtr, Uint32, Uint32, Pointer<Uint32>, Pointer<Void>, Pointer<Int32>);
typedef GetColorProfileElementDart = int Function(int, int, int, Pointer<Uint32>, Pointer<Void>, Pointer<Int32>);
final GetColorProfileElement = DynamicLibrary.open('mscms.dll')
    .lookupFunction<GetColorProfileElementNative, GetColorProfileElementDart>('GetColorProfileElement');
// hProfile : INT_PTR -> IntPtr
// tag : DWORD -> Uint32
// dwOffset : DWORD -> Uint32
// pcbElement : DWORD* in/out -> Pointer<Uint32>
// pElement : void* optional, out -> Pointer<Void>
// pbReference : BOOL* out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function GetColorProfileElement(
  hProfile: NativeInt;   // INT_PTR
  tag: DWORD;   // DWORD
  dwOffset: DWORD;   // DWORD
  pcbElement: Pointer;   // DWORD* in/out
  pElement: Pointer;   // void* optional, out
  pbReference: Pointer   // BOOL* out
): BOOL; stdcall;
  external 'mscms.dll' name 'GetColorProfileElement';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "GetColorProfileElement"
  c_GetColorProfileElement :: CIntPtr -> Word32 -> Word32 -> Ptr Word32 -> Ptr () -> Ptr CInt -> IO CInt
-- hProfile : INT_PTR -> CIntPtr
-- tag : DWORD -> Word32
-- dwOffset : DWORD -> Word32
-- pcbElement : DWORD* in/out -> Ptr Word32
-- pElement : void* optional, out -> Ptr ()
-- pbReference : BOOL* out -> Ptr CInt
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let getcolorprofileelement =
  foreign "GetColorProfileElement"
    (intptr_t @-> uint32_t @-> uint32_t @-> (ptr uint32_t) @-> (ptr void) @-> (ptr int32_t) @-> returning int32_t)
(* hProfile : INT_PTR -> intptr_t *)
(* tag : DWORD -> uint32_t *)
(* dwOffset : DWORD -> uint32_t *)
(* pcbElement : DWORD* in/out -> (ptr uint32_t) *)
(* pElement : void* optional, out -> (ptr void) *)
(* pbReference : BOOL* out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library mscms (t "mscms.dll"))
(cffi:use-foreign-library mscms)

(cffi:defcfun ("GetColorProfileElement" get-color-profile-element :convention :stdcall) :int32
  (h-profile :int64)   ; INT_PTR
  (tag :uint32)   ; DWORD
  (dw-offset :uint32)   ; DWORD
  (pcb-element :pointer)   ; DWORD* in/out
  (p-element :pointer)   ; void* optional, out
  (pb-reference :pointer))   ; BOOL* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $GetColorProfileElement = Win32::API::More->new('mscms',
    'BOOL GetColorProfileElement(LPARAM hProfile, DWORD tag, DWORD dwOffset, LPVOID pcbElement, LPVOID pElement, LPVOID pbReference)');
# my $ret = $GetColorProfileElement->Call($hProfile, $tag, $dwOffset, $pcbElement, $pElement, $pbReference);
# hProfile : INT_PTR -> LPARAM
# tag : DWORD -> DWORD
# dwOffset : DWORD -> DWORD
# pcbElement : DWORD* in/out -> LPVOID
# pElement : void* optional, out -> LPVOID
# pbReference : BOOL* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。