ホーム › UI.ColorSystem › CMCreateDeviceLinkProfile
CMCreateDeviceLinkProfile
関数CMMでデバイスリンクプロファイルを作成する。
シグネチャ
// ICM32.dll
#include <windows.h>
BOOL CMCreateDeviceLinkProfile(
INT_PTR* pahProfiles,
DWORD nProfiles,
DWORD* padwIntents,
DWORD nIntents,
DWORD dwFlags,
BYTE** lpProfileData
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pahProfiles | INT_PTR* | in | 連結するプロファイルハンドルの配列へのポインタ。 |
| nProfiles | DWORD | in | 配列内のプロファイル数。 |
| padwIntents | DWORD* | in | 各変換段で使用するレンダリングインテントのDWORD配列へのポインタ。 |
| nIntents | DWORD | in | インテント配列の要素数。 |
| dwFlags | DWORD | in | 変換生成時の最適化やガモットチェックを制御するフラグ。 |
| lpProfileData | BYTE** | out | 生成されたデバイスリンクプロファイルのデータバッファアドレスを受け取るポインタ。 |
戻り値の型: BOOL
各言語での呼び出し定義
// ICM32.dll
#include <windows.h>
BOOL CMCreateDeviceLinkProfile(
INT_PTR* pahProfiles,
DWORD nProfiles,
DWORD* padwIntents,
DWORD nIntents,
DWORD dwFlags,
BYTE** lpProfileData
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("ICM32.dll", ExactSpelling = true)]
static extern bool CMCreateDeviceLinkProfile(
ref IntPtr pahProfiles, // INT_PTR*
uint nProfiles, // DWORD
ref uint padwIntents, // DWORD*
uint nIntents, // DWORD
uint dwFlags, // DWORD
IntPtr lpProfileData // BYTE** out
);<DllImport("ICM32.dll", ExactSpelling:=True)>
Public Shared Function CMCreateDeviceLinkProfile(
ByRef pahProfiles As IntPtr, ' INT_PTR*
nProfiles As UInteger, ' DWORD
ByRef padwIntents As UInteger, ' DWORD*
nIntents As UInteger, ' DWORD
dwFlags As UInteger, ' DWORD
lpProfileData As IntPtr ' BYTE** out
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' pahProfiles : INT_PTR*
' nProfiles : DWORD
' padwIntents : DWORD*
' nIntents : DWORD
' dwFlags : DWORD
' lpProfileData : BYTE** out
Declare PtrSafe Function CMCreateDeviceLinkProfile Lib "icm32" ( _
ByRef pahProfiles As LongPtr, _
ByVal nProfiles As Long, _
ByRef padwIntents As Long, _
ByVal nIntents As Long, _
ByVal dwFlags As Long, _
ByVal lpProfileData As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CMCreateDeviceLinkProfile = ctypes.windll.icm32.CMCreateDeviceLinkProfile
CMCreateDeviceLinkProfile.restype = wintypes.BOOL
CMCreateDeviceLinkProfile.argtypes = [
ctypes.POINTER(ctypes.c_ssize_t), # pahProfiles : INT_PTR*
wintypes.DWORD, # nProfiles : DWORD
ctypes.POINTER(wintypes.DWORD), # padwIntents : DWORD*
wintypes.DWORD, # nIntents : DWORD
wintypes.DWORD, # dwFlags : DWORD
ctypes.c_void_p, # lpProfileData : BYTE** out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ICM32.dll')
CMCreateDeviceLinkProfile = Fiddle::Function.new(
lib['CMCreateDeviceLinkProfile'],
[
Fiddle::TYPE_VOIDP, # pahProfiles : INT_PTR*
-Fiddle::TYPE_INT, # nProfiles : DWORD
Fiddle::TYPE_VOIDP, # padwIntents : DWORD*
-Fiddle::TYPE_INT, # nIntents : DWORD
-Fiddle::TYPE_INT, # dwFlags : DWORD
Fiddle::TYPE_VOIDP, # lpProfileData : BYTE** out
],
Fiddle::TYPE_INT)#[link(name = "icm32")]
extern "system" {
fn CMCreateDeviceLinkProfile(
pahProfiles: *mut isize, // INT_PTR*
nProfiles: u32, // DWORD
padwIntents: *mut u32, // DWORD*
nIntents: u32, // DWORD
dwFlags: u32, // DWORD
lpProfileData: *mut *mut u8 // BYTE** out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("ICM32.dll")]
public static extern bool CMCreateDeviceLinkProfile(ref IntPtr pahProfiles, uint nProfiles, ref uint padwIntents, uint nIntents, uint dwFlags, IntPtr lpProfileData);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ICM32_CMCreateDeviceLinkProfile' -Namespace Win32 -PassThru
# $api::CMCreateDeviceLinkProfile(pahProfiles, nProfiles, padwIntents, nIntents, dwFlags, lpProfileData)#uselib "ICM32.dll"
#func global CMCreateDeviceLinkProfile "CMCreateDeviceLinkProfile" sptr, sptr, sptr, sptr, sptr, sptr
; CMCreateDeviceLinkProfile varptr(pahProfiles), nProfiles, varptr(padwIntents), nIntents, dwFlags, varptr(lpProfileData) ; 戻り値は stat
; pahProfiles : INT_PTR* -> "sptr"
; nProfiles : DWORD -> "sptr"
; padwIntents : DWORD* -> "sptr"
; nIntents : DWORD -> "sptr"
; dwFlags : DWORD -> "sptr"
; lpProfileData : BYTE** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "ICM32.dll" #cfunc global CMCreateDeviceLinkProfile "CMCreateDeviceLinkProfile" var, int, var, int, int, var ; res = CMCreateDeviceLinkProfile(pahProfiles, nProfiles, padwIntents, nIntents, dwFlags, lpProfileData) ; pahProfiles : INT_PTR* -> "var" ; nProfiles : DWORD -> "int" ; padwIntents : DWORD* -> "var" ; nIntents : DWORD -> "int" ; dwFlags : DWORD -> "int" ; lpProfileData : BYTE** out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ICM32.dll" #cfunc global CMCreateDeviceLinkProfile "CMCreateDeviceLinkProfile" sptr, int, sptr, int, int, sptr ; res = CMCreateDeviceLinkProfile(varptr(pahProfiles), nProfiles, varptr(padwIntents), nIntents, dwFlags, varptr(lpProfileData)) ; pahProfiles : INT_PTR* -> "sptr" ; nProfiles : DWORD -> "int" ; padwIntents : DWORD* -> "sptr" ; nIntents : DWORD -> "int" ; dwFlags : DWORD -> "int" ; lpProfileData : BYTE** out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL CMCreateDeviceLinkProfile(INT_PTR* pahProfiles, DWORD nProfiles, DWORD* padwIntents, DWORD nIntents, DWORD dwFlags, BYTE** lpProfileData) #uselib "ICM32.dll" #cfunc global CMCreateDeviceLinkProfile "CMCreateDeviceLinkProfile" var, int, var, int, int, var ; res = CMCreateDeviceLinkProfile(pahProfiles, nProfiles, padwIntents, nIntents, dwFlags, lpProfileData) ; pahProfiles : INT_PTR* -> "var" ; nProfiles : DWORD -> "int" ; padwIntents : DWORD* -> "var" ; nIntents : DWORD -> "int" ; dwFlags : DWORD -> "int" ; lpProfileData : BYTE** out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL CMCreateDeviceLinkProfile(INT_PTR* pahProfiles, DWORD nProfiles, DWORD* padwIntents, DWORD nIntents, DWORD dwFlags, BYTE** lpProfileData) #uselib "ICM32.dll" #cfunc global CMCreateDeviceLinkProfile "CMCreateDeviceLinkProfile" intptr, int, intptr, int, int, intptr ; res = CMCreateDeviceLinkProfile(varptr(pahProfiles), nProfiles, varptr(padwIntents), nIntents, dwFlags, varptr(lpProfileData)) ; pahProfiles : INT_PTR* -> "intptr" ; nProfiles : DWORD -> "int" ; padwIntents : DWORD* -> "intptr" ; nIntents : DWORD -> "int" ; dwFlags : DWORD -> "int" ; lpProfileData : BYTE** out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
icm32 = windows.NewLazySystemDLL("ICM32.dll")
procCMCreateDeviceLinkProfile = icm32.NewProc("CMCreateDeviceLinkProfile")
)
// pahProfiles (INT_PTR*), nProfiles (DWORD), padwIntents (DWORD*), nIntents (DWORD), dwFlags (DWORD), lpProfileData (BYTE** out)
r1, _, err := procCMCreateDeviceLinkProfile.Call(
uintptr(pahProfiles),
uintptr(nProfiles),
uintptr(padwIntents),
uintptr(nIntents),
uintptr(dwFlags),
uintptr(lpProfileData),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction CMCreateDeviceLinkProfile(
pahProfiles: Pointer; // INT_PTR*
nProfiles: DWORD; // DWORD
padwIntents: Pointer; // DWORD*
nIntents: DWORD; // DWORD
dwFlags: DWORD; // DWORD
lpProfileData: Pointer // BYTE** out
): BOOL; stdcall;
external 'ICM32.dll' name 'CMCreateDeviceLinkProfile';result := DllCall("ICM32\CMCreateDeviceLinkProfile"
, "Ptr", pahProfiles ; INT_PTR*
, "UInt", nProfiles ; DWORD
, "Ptr", padwIntents ; DWORD*
, "UInt", nIntents ; DWORD
, "UInt", dwFlags ; DWORD
, "Ptr", lpProfileData ; BYTE** out
, "Int") ; return: BOOL●CMCreateDeviceLinkProfile(pahProfiles, nProfiles, padwIntents, nIntents, dwFlags, lpProfileData) = DLL("ICM32.dll", "bool CMCreateDeviceLinkProfile(void*, dword, void*, dword, dword, void*)")
# 呼び出し: CMCreateDeviceLinkProfile(pahProfiles, nProfiles, padwIntents, nIntents, dwFlags, lpProfileData)
# pahProfiles : INT_PTR* -> "void*"
# nProfiles : DWORD -> "dword"
# padwIntents : DWORD* -> "void*"
# nIntents : DWORD -> "dword"
# dwFlags : DWORD -> "dword"
# lpProfileData : BYTE** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "icm32" fn CMCreateDeviceLinkProfile(
pahProfiles: [*c]isize, // INT_PTR*
nProfiles: u32, // DWORD
padwIntents: [*c]u32, // DWORD*
nIntents: u32, // DWORD
dwFlags: u32, // DWORD
lpProfileData: [*c][*c]u8 // BYTE** out
) callconv(std.os.windows.WINAPI) i32;proc CMCreateDeviceLinkProfile(
pahProfiles: ptr int, # INT_PTR*
nProfiles: uint32, # DWORD
padwIntents: ptr uint32, # DWORD*
nIntents: uint32, # DWORD
dwFlags: uint32, # DWORD
lpProfileData: ptr uint8 # BYTE** out
): int32 {.importc: "CMCreateDeviceLinkProfile", stdcall, dynlib: "ICM32.dll".}pragma(lib, "icm32");
extern(Windows)
int CMCreateDeviceLinkProfile(
ptrdiff_t* pahProfiles, // INT_PTR*
uint nProfiles, // DWORD
uint* padwIntents, // DWORD*
uint nIntents, // DWORD
uint dwFlags, // DWORD
ubyte** lpProfileData // BYTE** out
);ccall((:CMCreateDeviceLinkProfile, "ICM32.dll"), stdcall, Int32,
(Ptr{Int}, UInt32, Ptr{UInt32}, UInt32, UInt32, Ptr{UInt8}),
pahProfiles, nProfiles, padwIntents, nIntents, dwFlags, lpProfileData)
# pahProfiles : INT_PTR* -> Ptr{Int}
# nProfiles : DWORD -> UInt32
# padwIntents : DWORD* -> Ptr{UInt32}
# nIntents : DWORD -> UInt32
# dwFlags : DWORD -> UInt32
# lpProfileData : BYTE** out -> Ptr{UInt8}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t CMCreateDeviceLinkProfile(
intptr_t* pahProfiles,
uint32_t nProfiles,
uint32_t* padwIntents,
uint32_t nIntents,
uint32_t dwFlags,
uint8_t** lpProfileData);
]]
local icm32 = ffi.load("icm32")
-- icm32.CMCreateDeviceLinkProfile(pahProfiles, nProfiles, padwIntents, nIntents, dwFlags, lpProfileData)
-- pahProfiles : INT_PTR*
-- nProfiles : DWORD
-- padwIntents : DWORD*
-- nIntents : DWORD
-- dwFlags : DWORD
-- lpProfileData : BYTE** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('ICM32.dll');
const CMCreateDeviceLinkProfile = lib.func('__stdcall', 'CMCreateDeviceLinkProfile', 'int32_t', ['intptr_t *', 'uint32_t', 'uint32_t *', 'uint32_t', 'uint32_t', 'uint8_t *']);
// CMCreateDeviceLinkProfile(pahProfiles, nProfiles, padwIntents, nIntents, dwFlags, lpProfileData)
// pahProfiles : INT_PTR* -> 'intptr_t *'
// nProfiles : DWORD -> 'uint32_t'
// padwIntents : DWORD* -> 'uint32_t *'
// nIntents : DWORD -> 'uint32_t'
// dwFlags : DWORD -> 'uint32_t'
// lpProfileData : BYTE** out -> 'uint8_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("ICM32.dll", {
CMCreateDeviceLinkProfile: { parameters: ["pointer", "u32", "pointer", "u32", "u32", "pointer"], result: "i32" },
});
// lib.symbols.CMCreateDeviceLinkProfile(pahProfiles, nProfiles, padwIntents, nIntents, dwFlags, lpProfileData)
// pahProfiles : INT_PTR* -> "pointer"
// nProfiles : DWORD -> "u32"
// padwIntents : DWORD* -> "pointer"
// nIntents : DWORD -> "u32"
// dwFlags : DWORD -> "u32"
// lpProfileData : BYTE** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t CMCreateDeviceLinkProfile(
intptr_t* pahProfiles,
uint32_t nProfiles,
uint32_t* padwIntents,
uint32_t nIntents,
uint32_t dwFlags,
uint8_t** lpProfileData);
C, "ICM32.dll");
// $ffi->CMCreateDeviceLinkProfile(pahProfiles, nProfiles, padwIntents, nIntents, dwFlags, lpProfileData);
// pahProfiles : INT_PTR*
// nProfiles : DWORD
// padwIntents : DWORD*
// nIntents : DWORD
// dwFlags : DWORD
// lpProfileData : BYTE** 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 Icm32 extends StdCallLibrary {
Icm32 INSTANCE = Native.load("icm32", Icm32.class);
boolean CMCreateDeviceLinkProfile(
LongByReference pahProfiles, // INT_PTR*
int nProfiles, // DWORD
IntByReference padwIntents, // DWORD*
int nIntents, // DWORD
int dwFlags, // DWORD
Pointer lpProfileData // BYTE** out
);
}@[Link("icm32")]
lib LibICM32
fun CMCreateDeviceLinkProfile = CMCreateDeviceLinkProfile(
pahProfiles : LibC::SSizeT*, # INT_PTR*
nProfiles : UInt32, # DWORD
padwIntents : UInt32*, # DWORD*
nIntents : UInt32, # DWORD
dwFlags : UInt32, # DWORD
lpProfileData : UInt8** # BYTE** out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef CMCreateDeviceLinkProfileNative = Int32 Function(Pointer<IntPtr>, Uint32, Pointer<Uint32>, Uint32, Uint32, Pointer<Uint8>);
typedef CMCreateDeviceLinkProfileDart = int Function(Pointer<IntPtr>, int, Pointer<Uint32>, int, int, Pointer<Uint8>);
final CMCreateDeviceLinkProfile = DynamicLibrary.open('ICM32.dll')
.lookupFunction<CMCreateDeviceLinkProfileNative, CMCreateDeviceLinkProfileDart>('CMCreateDeviceLinkProfile');
// pahProfiles : INT_PTR* -> Pointer<IntPtr>
// nProfiles : DWORD -> Uint32
// padwIntents : DWORD* -> Pointer<Uint32>
// nIntents : DWORD -> Uint32
// dwFlags : DWORD -> Uint32
// lpProfileData : BYTE** out -> Pointer<Uint8>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function CMCreateDeviceLinkProfile(
pahProfiles: Pointer; // INT_PTR*
nProfiles: DWORD; // DWORD
padwIntents: Pointer; // DWORD*
nIntents: DWORD; // DWORD
dwFlags: DWORD; // DWORD
lpProfileData: Pointer // BYTE** out
): BOOL; stdcall;
external 'ICM32.dll' name 'CMCreateDeviceLinkProfile';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "CMCreateDeviceLinkProfile"
c_CMCreateDeviceLinkProfile :: Ptr CIntPtr -> Word32 -> Ptr Word32 -> Word32 -> Word32 -> Ptr Word8 -> IO CInt
-- pahProfiles : INT_PTR* -> Ptr CIntPtr
-- nProfiles : DWORD -> Word32
-- padwIntents : DWORD* -> Ptr Word32
-- nIntents : DWORD -> Word32
-- dwFlags : DWORD -> Word32
-- lpProfileData : BYTE** out -> Ptr Word8
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let cmcreatedevicelinkprofile =
foreign "CMCreateDeviceLinkProfile"
((ptr intptr_t) @-> uint32_t @-> (ptr uint32_t) @-> uint32_t @-> uint32_t @-> (ptr uint8_t) @-> returning int32_t)
(* pahProfiles : INT_PTR* -> (ptr intptr_t) *)
(* nProfiles : DWORD -> uint32_t *)
(* padwIntents : DWORD* -> (ptr uint32_t) *)
(* nIntents : DWORD -> uint32_t *)
(* dwFlags : DWORD -> uint32_t *)
(* lpProfileData : BYTE** out -> (ptr uint8_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library icm32 (t "ICM32.dll"))
(cffi:use-foreign-library icm32)
(cffi:defcfun ("CMCreateDeviceLinkProfile" cmcreate-device-link-profile :convention :stdcall) :int32
(pah-profiles :pointer) ; INT_PTR*
(n-profiles :uint32) ; DWORD
(padw-intents :pointer) ; DWORD*
(n-intents :uint32) ; DWORD
(dw-flags :uint32) ; DWORD
(lp-profile-data :pointer)) ; BYTE** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $CMCreateDeviceLinkProfile = Win32::API::More->new('ICM32',
'BOOL CMCreateDeviceLinkProfile(LPVOID pahProfiles, DWORD nProfiles, LPVOID padwIntents, DWORD nIntents, DWORD dwFlags, LPVOID lpProfileData)');
# my $ret = $CMCreateDeviceLinkProfile->Call($pahProfiles, $nProfiles, $padwIntents, $nIntents, $dwFlags, $lpProfileData);
# pahProfiles : INT_PTR* -> LPVOID
# nProfiles : DWORD -> DWORD
# padwIntents : DWORD* -> LPVOID
# nIntents : DWORD -> DWORD
# dwFlags : DWORD -> DWORD
# lpProfileData : BYTE** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。