ホーム › UI.ColorSystem › GetColorProfileFromHandle
GetColorProfileFromHandle
関数プロファイルハンドルからプロファイルデータを取得する。
シグネチャ
// mscms.dll
#include <windows.h>
BOOL GetColorProfileFromHandle(
INT_PTR hProfile,
BYTE* pProfile, // optional
DWORD* pcbProfile
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hProfile | INT_PTR | in | 内容を取得する対象のカラープロファイルハンドル。 |
| pProfile | BYTE* | outoptional | プロファイルの生データを受け取るバッファ。NULLでサイズ問い合わせが可能。 |
| pcbProfile | DWORD* | 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 <MarshalAs(UnmanagedType.Bool)> 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 方式にも切替可。#uselib "mscms.dll" #cfunc global GetColorProfileFromHandle "GetColorProfileFromHandle" sptr, sptr, sptr ; res = GetColorProfileFromHandle(hProfile, varptr(pProfile), varptr(pcbProfile)) ; hProfile : INT_PTR -> "sptr" ; pProfile : BYTE* optional, out -> "sptr" ; pcbProfile : DWORD* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは 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 方式にも切替可。; BOOL GetColorProfileFromHandle(INT_PTR hProfile, BYTE* pProfile, DWORD* pcbProfile) #uselib "mscms.dll" #cfunc global GetColorProfileFromHandle "GetColorProfileFromHandle" intptr, intptr, intptr ; res = GetColorProfileFromHandle(hProfile, varptr(pProfile), varptr(pcbProfile)) ; hProfile : INT_PTR -> "intptr" ; pProfile : BYTE* optional, out -> "intptr" ; pcbProfile : DWORD* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは 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 // BOOLfunction 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)。const std = @import("std");
extern "mscms" fn GetColorProfileFromHandle(
hProfile: isize, // INT_PTR
pProfile: [*c]u8, // BYTE* optional, out
pcbProfile: [*c]u32 // DWORD* in/out
) callconv(std.os.windows.WINAPI) i32;proc GetColorProfileFromHandle(
hProfile: int, # INT_PTR
pProfile: ptr uint8, # BYTE* optional, out
pcbProfile: ptr uint32 # DWORD* in/out
): int32 {.importc: "GetColorProfileFromHandle", stdcall, dynlib: "mscms.dll".}pragma(lib, "mscms");
extern(Windows)
int GetColorProfileFromHandle(
ptrdiff_t hProfile, // INT_PTR
ubyte* pProfile, // BYTE* optional, out
uint* pcbProfile // DWORD* in/out
);ccall((:GetColorProfileFromHandle, "mscms.dll"), stdcall, Int32,
(Int, Ptr{UInt8}, Ptr{UInt32}),
hProfile, pProfile, pcbProfile)
# hProfile : INT_PTR -> Int
# pProfile : BYTE* optional, out -> Ptr{UInt8}
# pcbProfile : DWORD* in/out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t GetColorProfileFromHandle(
intptr_t hProfile,
uint8_t* pProfile,
uint32_t* pcbProfile);
]]
local mscms = ffi.load("mscms")
-- mscms.GetColorProfileFromHandle(hProfile, pProfile, pcbProfile)
-- hProfile : INT_PTR
-- pProfile : BYTE* optional, out
-- pcbProfile : DWORD* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('mscms.dll');
const GetColorProfileFromHandle = lib.func('__stdcall', 'GetColorProfileFromHandle', 'int32_t', ['intptr_t', 'uint8_t *', 'uint32_t *']);
// GetColorProfileFromHandle(hProfile, pProfile, pcbProfile)
// hProfile : INT_PTR -> 'intptr_t'
// pProfile : BYTE* optional, out -> 'uint8_t *'
// pcbProfile : DWORD* in/out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("mscms.dll", {
GetColorProfileFromHandle: { parameters: ["isize", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.GetColorProfileFromHandle(hProfile, pProfile, pcbProfile)
// hProfile : INT_PTR -> "isize"
// pProfile : BYTE* optional, out -> "pointer"
// pcbProfile : DWORD* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t GetColorProfileFromHandle(
intptr_t hProfile,
uint8_t* pProfile,
uint32_t* pcbProfile);
C, "mscms.dll");
// $ffi->GetColorProfileFromHandle(hProfile, pProfile, pcbProfile);
// hProfile : INT_PTR
// pProfile : BYTE* optional, out
// pcbProfile : DWORD* in/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 GetColorProfileFromHandle(
long hProfile, // INT_PTR
byte[] pProfile, // BYTE* optional, out
IntByReference pcbProfile // DWORD* in/out
);
}@[Link("mscms")]
lib Libmscms
fun GetColorProfileFromHandle = GetColorProfileFromHandle(
hProfile : LibC::SSizeT, # INT_PTR
pProfile : UInt8*, # BYTE* optional, out
pcbProfile : UInt32* # DWORD* in/out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef GetColorProfileFromHandleNative = Int32 Function(IntPtr, Pointer<Uint8>, Pointer<Uint32>);
typedef GetColorProfileFromHandleDart = int Function(int, Pointer<Uint8>, Pointer<Uint32>);
final GetColorProfileFromHandle = DynamicLibrary.open('mscms.dll')
.lookupFunction<GetColorProfileFromHandleNative, GetColorProfileFromHandleDart>('GetColorProfileFromHandle');
// hProfile : INT_PTR -> IntPtr
// pProfile : BYTE* optional, out -> Pointer<Uint8>
// pcbProfile : DWORD* in/out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function GetColorProfileFromHandle(
hProfile: NativeInt; // INT_PTR
pProfile: Pointer; // BYTE* optional, out
pcbProfile: Pointer // DWORD* in/out
): BOOL; stdcall;
external 'mscms.dll' name 'GetColorProfileFromHandle';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "GetColorProfileFromHandle"
c_GetColorProfileFromHandle :: CIntPtr -> Ptr Word8 -> Ptr Word32 -> IO CInt
-- hProfile : INT_PTR -> CIntPtr
-- pProfile : BYTE* optional, out -> Ptr Word8
-- pcbProfile : DWORD* in/out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let getcolorprofilefromhandle =
foreign "GetColorProfileFromHandle"
(intptr_t @-> (ptr uint8_t) @-> (ptr uint32_t) @-> returning int32_t)
(* hProfile : INT_PTR -> intptr_t *)
(* pProfile : BYTE* optional, out -> (ptr uint8_t) *)
(* pcbProfile : DWORD* in/out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library mscms (t "mscms.dll"))
(cffi:use-foreign-library mscms)
(cffi:defcfun ("GetColorProfileFromHandle" get-color-profile-from-handle :convention :stdcall) :int32
(h-profile :int64) ; INT_PTR
(p-profile :pointer) ; BYTE* optional, out
(pcb-profile :pointer)) ; DWORD* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $GetColorProfileFromHandle = Win32::API::More->new('mscms',
'BOOL GetColorProfileFromHandle(LPARAM hProfile, LPVOID pProfile, LPVOID pcbProfile)');
# my $ret = $GetColorProfileFromHandle->Call($hProfile, $pProfile, $pcbProfile);
# hProfile : INT_PTR -> LPARAM
# pProfile : BYTE* optional, out -> LPVOID
# pcbProfile : DWORD* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。