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

CMCreateProfile

関数
CMMで論理色空間からプロファイルを作成する(ANSI版)。
DLLICM32.dll文字セットANSI (-A)呼出規約winapi

シグネチャ

// ICM32.dll  (ANSI / -A)
#include <windows.h>

BOOL CMCreateProfile(
    LOGCOLORSPACEA* lpColorSpace,
    void** lpProfileData
);

パラメーター

名前方向
lpColorSpaceLOGCOLORSPACEA*inout
lpProfileDatavoid**out

戻り値の型: BOOL

各言語での呼び出し定義

// ICM32.dll  (ANSI / -A)
#include <windows.h>

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

CMCreateProfile = ctypes.windll.icm32.CMCreateProfile
CMCreateProfile.restype = wintypes.BOOL
CMCreateProfile.argtypes = [
    ctypes.c_void_p,  # lpColorSpace : LOGCOLORSPACEA* in/out
    ctypes.c_void_p,  # lpProfileData : void** out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	icm32 = windows.NewLazySystemDLL("ICM32.dll")
	procCMCreateProfile = icm32.NewProc("CMCreateProfile")
)

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