ホーム › UI.ColorSystem › OpenColorProfileA
OpenColorProfileA
関数カラープロファイルを開いてハンドルを取得する(ANSI版)。
シグネチャ
// mscms.dll (ANSI / -A)
#include <windows.h>
INT_PTR OpenColorProfileA(
PROFILE* pProfile,
DWORD dwDesiredAccess,
DWORD dwShareMode,
DWORD dwCreationMode
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pProfile | PROFILE* | in | 開くカラープロファイルを記述するPROFILE構造体(ANSI)へのポインタ。 |
| dwDesiredAccess | DWORD | in | プロファイルへのアクセス権を指定するフラグ。読み取り・書き込みなどを指定する。 |
| dwShareMode | DWORD | in | 他プロセスとの共有モードを指定するフラグ。読み取り共有・書き込み共有など。 |
| dwCreationMode | DWORD | in | プロファイルを開く際の作成動作を指定する値。既存・新規作成などを指定する。 |
戻り値の型: INT_PTR
各言語での呼び出し定義
// mscms.dll (ANSI / -A)
#include <windows.h>
INT_PTR OpenColorProfileA(
PROFILE* pProfile,
DWORD dwDesiredAccess,
DWORD dwShareMode,
DWORD dwCreationMode
);[DllImport("mscms.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern IntPtr OpenColorProfileA(
IntPtr pProfile, // PROFILE*
uint dwDesiredAccess, // DWORD
uint dwShareMode, // DWORD
uint dwCreationMode // DWORD
);<DllImport("mscms.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function OpenColorProfileA(
pProfile As IntPtr, ' PROFILE*
dwDesiredAccess As UInteger, ' DWORD
dwShareMode As UInteger, ' DWORD
dwCreationMode As UInteger ' DWORD
) As IntPtr
End Function' pProfile : PROFILE*
' dwDesiredAccess : DWORD
' dwShareMode : DWORD
' dwCreationMode : DWORD
Declare PtrSafe Function OpenColorProfileA Lib "mscms" ( _
ByVal pProfile As LongPtr, _
ByVal dwDesiredAccess As Long, _
ByVal dwShareMode As Long, _
ByVal dwCreationMode As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
OpenColorProfileA = ctypes.windll.mscms.OpenColorProfileA
OpenColorProfileA.restype = ctypes.c_ssize_t
OpenColorProfileA.argtypes = [
ctypes.c_void_p, # pProfile : PROFILE*
wintypes.DWORD, # dwDesiredAccess : DWORD
wintypes.DWORD, # dwShareMode : DWORD
wintypes.DWORD, # dwCreationMode : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('mscms.dll')
OpenColorProfileA = Fiddle::Function.new(
lib['OpenColorProfileA'],
[
Fiddle::TYPE_VOIDP, # pProfile : PROFILE*
-Fiddle::TYPE_INT, # dwDesiredAccess : DWORD
-Fiddle::TYPE_INT, # dwShareMode : DWORD
-Fiddle::TYPE_INT, # dwCreationMode : DWORD
],
Fiddle::TYPE_INTPTR_T)#[link(name = "mscms")]
extern "system" {
fn OpenColorProfileA(
pProfile: *mut PROFILE, // PROFILE*
dwDesiredAccess: u32, // DWORD
dwShareMode: u32, // DWORD
dwCreationMode: u32 // DWORD
) -> isize;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("mscms.dll", CharSet = CharSet.Ansi)]
public static extern IntPtr OpenColorProfileA(IntPtr pProfile, uint dwDesiredAccess, uint dwShareMode, uint dwCreationMode);
"@
$api = Add-Type -MemberDefinition $sig -Name 'mscms_OpenColorProfileA' -Namespace Win32 -PassThru
# $api::OpenColorProfileA(pProfile, dwDesiredAccess, dwShareMode, dwCreationMode)#uselib "mscms.dll"
#func global OpenColorProfileA "OpenColorProfileA" sptr, sptr, sptr, sptr
; OpenColorProfileA varptr(pProfile), dwDesiredAccess, dwShareMode, dwCreationMode ; 戻り値は stat
; pProfile : PROFILE* -> "sptr"
; dwDesiredAccess : DWORD -> "sptr"
; dwShareMode : DWORD -> "sptr"
; dwCreationMode : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "mscms.dll" #cfunc global OpenColorProfileA "OpenColorProfileA" var, int, int, int ; res = OpenColorProfileA(pProfile, dwDesiredAccess, dwShareMode, dwCreationMode) ; pProfile : PROFILE* -> "var" ; dwDesiredAccess : DWORD -> "int" ; dwShareMode : DWORD -> "int" ; dwCreationMode : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "mscms.dll" #cfunc global OpenColorProfileA "OpenColorProfileA" sptr, int, int, int ; res = OpenColorProfileA(varptr(pProfile), dwDesiredAccess, dwShareMode, dwCreationMode) ; pProfile : PROFILE* -> "sptr" ; dwDesiredAccess : DWORD -> "int" ; dwShareMode : DWORD -> "int" ; dwCreationMode : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT_PTR OpenColorProfileA(PROFILE* pProfile, DWORD dwDesiredAccess, DWORD dwShareMode, DWORD dwCreationMode) #uselib "mscms.dll" #cfunc global OpenColorProfileA "OpenColorProfileA" var, int, int, int ; res = OpenColorProfileA(pProfile, dwDesiredAccess, dwShareMode, dwCreationMode) ; pProfile : PROFILE* -> "var" ; dwDesiredAccess : DWORD -> "int" ; dwShareMode : DWORD -> "int" ; dwCreationMode : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT_PTR OpenColorProfileA(PROFILE* pProfile, DWORD dwDesiredAccess, DWORD dwShareMode, DWORD dwCreationMode) #uselib "mscms.dll" #cfunc global OpenColorProfileA "OpenColorProfileA" intptr, int, int, int ; res = OpenColorProfileA(varptr(pProfile), dwDesiredAccess, dwShareMode, dwCreationMode) ; pProfile : PROFILE* -> "intptr" ; dwDesiredAccess : DWORD -> "int" ; dwShareMode : DWORD -> "int" ; dwCreationMode : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
mscms = windows.NewLazySystemDLL("mscms.dll")
procOpenColorProfileA = mscms.NewProc("OpenColorProfileA")
)
// pProfile (PROFILE*), dwDesiredAccess (DWORD), dwShareMode (DWORD), dwCreationMode (DWORD)
r1, _, err := procOpenColorProfileA.Call(
uintptr(pProfile),
uintptr(dwDesiredAccess),
uintptr(dwShareMode),
uintptr(dwCreationMode),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INT_PTRfunction OpenColorProfileA(
pProfile: Pointer; // PROFILE*
dwDesiredAccess: DWORD; // DWORD
dwShareMode: DWORD; // DWORD
dwCreationMode: DWORD // DWORD
): NativeInt; stdcall;
external 'mscms.dll' name 'OpenColorProfileA';result := DllCall("mscms\OpenColorProfileA"
, "Ptr", pProfile ; PROFILE*
, "UInt", dwDesiredAccess ; DWORD
, "UInt", dwShareMode ; DWORD
, "UInt", dwCreationMode ; DWORD
, "Ptr") ; return: INT_PTR●OpenColorProfileA(pProfile, dwDesiredAccess, dwShareMode, dwCreationMode) = DLL("mscms.dll", "int OpenColorProfileA(void*, dword, dword, dword)")
# 呼び出し: OpenColorProfileA(pProfile, dwDesiredAccess, dwShareMode, dwCreationMode)
# pProfile : PROFILE* -> "void*"
# dwDesiredAccess : DWORD -> "dword"
# dwShareMode : DWORD -> "dword"
# dwCreationMode : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "mscms" fn OpenColorProfileA(
pProfile: [*c]PROFILE, // PROFILE*
dwDesiredAccess: u32, // DWORD
dwShareMode: u32, // DWORD
dwCreationMode: u32 // DWORD
) callconv(std.os.windows.WINAPI) isize;proc OpenColorProfileA(
pProfile: ptr PROFILE, # PROFILE*
dwDesiredAccess: uint32, # DWORD
dwShareMode: uint32, # DWORD
dwCreationMode: uint32 # DWORD
): int {.importc: "OpenColorProfileA", stdcall, dynlib: "mscms.dll".}pragma(lib, "mscms");
extern(Windows)
ptrdiff_t OpenColorProfileA(
PROFILE* pProfile, // PROFILE*
uint dwDesiredAccess, // DWORD
uint dwShareMode, // DWORD
uint dwCreationMode // DWORD
);ccall((:OpenColorProfileA, "mscms.dll"), stdcall, Int,
(Ptr{PROFILE}, UInt32, UInt32, UInt32),
pProfile, dwDesiredAccess, dwShareMode, dwCreationMode)
# pProfile : PROFILE* -> Ptr{PROFILE}
# dwDesiredAccess : DWORD -> UInt32
# dwShareMode : DWORD -> UInt32
# dwCreationMode : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
intptr_t OpenColorProfileA(
void* pProfile,
uint32_t dwDesiredAccess,
uint32_t dwShareMode,
uint32_t dwCreationMode);
]]
local mscms = ffi.load("mscms")
-- mscms.OpenColorProfileA(pProfile, dwDesiredAccess, dwShareMode, dwCreationMode)
-- pProfile : PROFILE*
-- dwDesiredAccess : DWORD
-- dwShareMode : DWORD
-- dwCreationMode : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('mscms.dll');
const OpenColorProfileA = lib.func('__stdcall', 'OpenColorProfileA', 'intptr_t', ['void *', 'uint32_t', 'uint32_t', 'uint32_t']);
// OpenColorProfileA(pProfile, dwDesiredAccess, dwShareMode, dwCreationMode)
// pProfile : PROFILE* -> 'void *'
// dwDesiredAccess : DWORD -> 'uint32_t'
// dwShareMode : DWORD -> 'uint32_t'
// dwCreationMode : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("mscms.dll", {
OpenColorProfileA: { parameters: ["pointer", "u32", "u32", "u32"], result: "isize" },
});
// lib.symbols.OpenColorProfileA(pProfile, dwDesiredAccess, dwShareMode, dwCreationMode)
// pProfile : PROFILE* -> "pointer"
// dwDesiredAccess : DWORD -> "u32"
// dwShareMode : DWORD -> "u32"
// dwCreationMode : DWORD -> "u32"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
intptr_t OpenColorProfileA(
void* pProfile,
uint32_t dwDesiredAccess,
uint32_t dwShareMode,
uint32_t dwCreationMode);
C, "mscms.dll");
// $ffi->OpenColorProfileA(pProfile, dwDesiredAccess, dwShareMode, dwCreationMode);
// pProfile : PROFILE*
// dwDesiredAccess : DWORD
// dwShareMode : DWORD
// dwCreationMode : DWORD
// 構造体/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, W32APIOptions.ASCII_OPTIONS);
long OpenColorProfileA(
Pointer pProfile, // PROFILE*
int dwDesiredAccess, // DWORD
int dwShareMode, // DWORD
int dwCreationMode // DWORD
);
}@[Link("mscms")]
lib Libmscms
fun OpenColorProfileA = OpenColorProfileA(
pProfile : PROFILE*, # PROFILE*
dwDesiredAccess : UInt32, # DWORD
dwShareMode : UInt32, # DWORD
dwCreationMode : UInt32 # DWORD
) : LibC::SSizeT
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef OpenColorProfileANative = IntPtr Function(Pointer<Void>, Uint32, Uint32, Uint32);
typedef OpenColorProfileADart = int Function(Pointer<Void>, int, int, int);
final OpenColorProfileA = DynamicLibrary.open('mscms.dll')
.lookupFunction<OpenColorProfileANative, OpenColorProfileADart>('OpenColorProfileA');
// pProfile : PROFILE* -> Pointer<Void>
// dwDesiredAccess : DWORD -> Uint32
// dwShareMode : DWORD -> Uint32
// dwCreationMode : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function OpenColorProfileA(
pProfile: Pointer; // PROFILE*
dwDesiredAccess: DWORD; // DWORD
dwShareMode: DWORD; // DWORD
dwCreationMode: DWORD // DWORD
): NativeInt; stdcall;
external 'mscms.dll' name 'OpenColorProfileA';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "OpenColorProfileA"
c_OpenColorProfileA :: Ptr () -> Word32 -> Word32 -> Word32 -> IO CIntPtr
-- pProfile : PROFILE* -> Ptr ()
-- dwDesiredAccess : DWORD -> Word32
-- dwShareMode : DWORD -> Word32
-- dwCreationMode : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let opencolorprofilea =
foreign "OpenColorProfileA"
((ptr void) @-> uint32_t @-> uint32_t @-> uint32_t @-> returning intptr_t)
(* pProfile : PROFILE* -> (ptr void) *)
(* dwDesiredAccess : DWORD -> uint32_t *)
(* dwShareMode : DWORD -> uint32_t *)
(* dwCreationMode : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library mscms (t "mscms.dll"))
(cffi:use-foreign-library mscms)
(cffi:defcfun ("OpenColorProfileA" open-color-profile-a :convention :stdcall) :int64
(p-profile :pointer) ; PROFILE*
(dw-desired-access :uint32) ; DWORD
(dw-share-mode :uint32) ; DWORD
(dw-creation-mode :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $OpenColorProfileA = Win32::API::More->new('mscms',
'LPARAM OpenColorProfileA(LPVOID pProfile, DWORD dwDesiredAccess, DWORD dwShareMode, DWORD dwCreationMode)');
# my $ret = $OpenColorProfileA->Call($pProfile, $dwDesiredAccess, $dwShareMode, $dwCreationMode);
# pProfile : PROFILE* -> LPVOID
# dwDesiredAccess : DWORD -> DWORD
# dwShareMode : DWORD -> DWORD
# dwCreationMode : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
文字セット違い
- f OpenColorProfileW (Unicode版) — カラープロファイルを開いてハンドルを取得する(Unicode版)。
使用する型