ホーム › UI.ColorSystem › OpenColorProfileW
OpenColorProfileW
関数カラープロファイルを開いてハンドルを取得する(Unicode版)。
シグネチャ
// mscms.dll (Unicode / -W)
#include <windows.h>
INT_PTR OpenColorProfileW(
PROFILE* pProfile,
DWORD dwDesiredAccess,
DWORD dwShareMode,
DWORD dwCreationMode
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pProfile | PROFILE* | in | 開くカラープロファイルを記述するPROFILE構造体(Unicode)へのポインタ。 |
| dwDesiredAccess | DWORD | in | プロファイルへのアクセス権を指定するフラグ。読み取り・書き込みなどを指定する。 |
| dwShareMode | DWORD | in | 他プロセスとの共有モードを指定するフラグ。読み取り共有・書き込み共有など。 |
| dwCreationMode | DWORD | in | プロファイルを開く際の作成動作を指定する値。既存・新規作成などを指定する。 |
戻り値の型: INT_PTR
各言語での呼び出し定義
// mscms.dll (Unicode / -W)
#include <windows.h>
INT_PTR OpenColorProfileW(
PROFILE* pProfile,
DWORD dwDesiredAccess,
DWORD dwShareMode,
DWORD dwCreationMode
);[DllImport("mscms.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern IntPtr OpenColorProfileW(
IntPtr pProfile, // PROFILE*
uint dwDesiredAccess, // DWORD
uint dwShareMode, // DWORD
uint dwCreationMode // DWORD
);<DllImport("mscms.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function OpenColorProfileW(
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 OpenColorProfileW Lib "mscms" ( _
ByVal pProfile As LongPtr, _
ByVal dwDesiredAccess As Long, _
ByVal dwShareMode As Long, _
ByVal dwCreationMode As Long) As LongPtr
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
OpenColorProfileW = ctypes.windll.mscms.OpenColorProfileW
OpenColorProfileW.restype = ctypes.c_ssize_t
OpenColorProfileW.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')
OpenColorProfileW = Fiddle::Function.new(
lib['OpenColorProfileW'],
[
Fiddle::TYPE_VOIDP, # pProfile : PROFILE*
-Fiddle::TYPE_INT, # dwDesiredAccess : DWORD
-Fiddle::TYPE_INT, # dwShareMode : DWORD
-Fiddle::TYPE_INT, # dwCreationMode : DWORD
],
Fiddle::TYPE_INTPTR_T)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "mscms")]
extern "system" {
fn OpenColorProfileW(
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.Unicode)]
public static extern IntPtr OpenColorProfileW(IntPtr pProfile, uint dwDesiredAccess, uint dwShareMode, uint dwCreationMode);
"@
$api = Add-Type -MemberDefinition $sig -Name 'mscms_OpenColorProfileW' -Namespace Win32 -PassThru
# $api::OpenColorProfileW(pProfile, dwDesiredAccess, dwShareMode, dwCreationMode)#uselib "mscms.dll"
#func global OpenColorProfileW "OpenColorProfileW" wptr, wptr, wptr, wptr
; OpenColorProfileW varptr(pProfile), dwDesiredAccess, dwShareMode, dwCreationMode ; 戻り値は stat
; pProfile : PROFILE* -> "wptr"
; dwDesiredAccess : DWORD -> "wptr"
; dwShareMode : DWORD -> "wptr"
; dwCreationMode : DWORD -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "mscms.dll" #cfunc global OpenColorProfileW "OpenColorProfileW" var, int, int, int ; res = OpenColorProfileW(pProfile, dwDesiredAccess, dwShareMode, dwCreationMode) ; pProfile : PROFILE* -> "var" ; dwDesiredAccess : DWORD -> "int" ; dwShareMode : DWORD -> "int" ; dwCreationMode : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "mscms.dll" #cfunc global OpenColorProfileW "OpenColorProfileW" sptr, int, int, int ; res = OpenColorProfileW(varptr(pProfile), dwDesiredAccess, dwShareMode, dwCreationMode) ; pProfile : PROFILE* -> "sptr" ; dwDesiredAccess : DWORD -> "int" ; dwShareMode : DWORD -> "int" ; dwCreationMode : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT_PTR OpenColorProfileW(PROFILE* pProfile, DWORD dwDesiredAccess, DWORD dwShareMode, DWORD dwCreationMode) #uselib "mscms.dll" #cfunc global OpenColorProfileW "OpenColorProfileW" var, int, int, int ; res = OpenColorProfileW(pProfile, dwDesiredAccess, dwShareMode, dwCreationMode) ; pProfile : PROFILE* -> "var" ; dwDesiredAccess : DWORD -> "int" ; dwShareMode : DWORD -> "int" ; dwCreationMode : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT_PTR OpenColorProfileW(PROFILE* pProfile, DWORD dwDesiredAccess, DWORD dwShareMode, DWORD dwCreationMode) #uselib "mscms.dll" #cfunc global OpenColorProfileW "OpenColorProfileW" intptr, int, int, int ; res = OpenColorProfileW(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")
procOpenColorProfileW = mscms.NewProc("OpenColorProfileW")
)
// pProfile (PROFILE*), dwDesiredAccess (DWORD), dwShareMode (DWORD), dwCreationMode (DWORD)
r1, _, err := procOpenColorProfileW.Call(
uintptr(pProfile),
uintptr(dwDesiredAccess),
uintptr(dwShareMode),
uintptr(dwCreationMode),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INT_PTRfunction OpenColorProfileW(
pProfile: Pointer; // PROFILE*
dwDesiredAccess: DWORD; // DWORD
dwShareMode: DWORD; // DWORD
dwCreationMode: DWORD // DWORD
): NativeInt; stdcall;
external 'mscms.dll' name 'OpenColorProfileW';result := DllCall("mscms\OpenColorProfileW"
, "Ptr", pProfile ; PROFILE*
, "UInt", dwDesiredAccess ; DWORD
, "UInt", dwShareMode ; DWORD
, "UInt", dwCreationMode ; DWORD
, "Ptr") ; return: INT_PTR●OpenColorProfileW(pProfile, dwDesiredAccess, dwShareMode, dwCreationMode) = DLL("mscms.dll", "int OpenColorProfileW(void*, dword, dword, dword)")
# 呼び出し: OpenColorProfileW(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)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。const std = @import("std");
extern "mscms" fn OpenColorProfileW(
pProfile: [*c]PROFILE, // PROFILE*
dwDesiredAccess: u32, // DWORD
dwShareMode: u32, // DWORD
dwCreationMode: u32 // DWORD
) callconv(std.os.windows.WINAPI) isize;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc OpenColorProfileW(
pProfile: ptr PROFILE, # PROFILE*
dwDesiredAccess: uint32, # DWORD
dwShareMode: uint32, # DWORD
dwCreationMode: uint32 # DWORD
): int {.importc: "OpenColorProfileW", stdcall, dynlib: "mscms.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "mscms");
extern(Windows)
ptrdiff_t OpenColorProfileW(
PROFILE* pProfile, // PROFILE*
uint dwDesiredAccess, // DWORD
uint dwShareMode, // DWORD
uint dwCreationMode // DWORD
);ccall((:OpenColorProfileW, "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 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
intptr_t OpenColorProfileW(
void* pProfile,
uint32_t dwDesiredAccess,
uint32_t dwShareMode,
uint32_t dwCreationMode);
]]
local mscms = ffi.load("mscms")
-- mscms.OpenColorProfileW(pProfile, dwDesiredAccess, dwShareMode, dwCreationMode)
-- pProfile : PROFILE*
-- dwDesiredAccess : DWORD
-- dwShareMode : DWORD
-- dwCreationMode : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。const koffi = require('koffi');
const lib = koffi.load('mscms.dll');
const OpenColorProfileW = lib.func('__stdcall', 'OpenColorProfileW', 'intptr_t', ['void *', 'uint32_t', 'uint32_t', 'uint32_t']);
// OpenColorProfileW(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", {
OpenColorProfileW: { parameters: ["pointer", "u32", "u32", "u32"], result: "isize" },
});
// lib.symbols.OpenColorProfileW(pProfile, dwDesiredAccess, dwShareMode, dwCreationMode)
// pProfile : PROFILE* -> "pointer"
// dwDesiredAccess : DWORD -> "u32"
// dwShareMode : DWORD -> "u32"
// dwCreationMode : DWORD -> "u32"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
intptr_t OpenColorProfileW(
void* pProfile,
uint32_t dwDesiredAccess,
uint32_t dwShareMode,
uint32_t dwCreationMode);
C, "mscms.dll");
// $ffi->OpenColorProfileW(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.UNICODE_OPTIONS);
long OpenColorProfileW(
Pointer pProfile, // PROFILE*
int dwDesiredAccess, // DWORD
int dwShareMode, // DWORD
int dwCreationMode // DWORD
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("mscms")]
lib Libmscms
fun OpenColorProfileW = OpenColorProfileW(
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 OpenColorProfileWNative = IntPtr Function(Pointer<Void>, Uint32, Uint32, Uint32);
typedef OpenColorProfileWDart = int Function(Pointer<Void>, int, int, int);
final OpenColorProfileW = DynamicLibrary.open('mscms.dll')
.lookupFunction<OpenColorProfileWNative, OpenColorProfileWDart>('OpenColorProfileW');
// pProfile : PROFILE* -> Pointer<Void>
// dwDesiredAccess : DWORD -> Uint32
// dwShareMode : DWORD -> Uint32
// dwCreationMode : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function OpenColorProfileW(
pProfile: Pointer; // PROFILE*
dwDesiredAccess: DWORD; // DWORD
dwShareMode: DWORD; // DWORD
dwCreationMode: DWORD // DWORD
): NativeInt; stdcall;
external 'mscms.dll' name 'OpenColorProfileW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "OpenColorProfileW"
c_OpenColorProfileW :: 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 opencolorprofilew =
foreign "OpenColorProfileW"
((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 ("OpenColorProfileW" open-color-profile-w :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 $OpenColorProfileW = Win32::API::More->new('mscms',
'LPARAM OpenColorProfileW(LPVOID pProfile, DWORD dwDesiredAccess, DWORD dwShareMode, DWORD dwCreationMode)');
# my $ret = $OpenColorProfileW->Call($pProfile, $dwDesiredAccess, $dwShareMode, $dwCreationMode);
# pProfile : PROFILE* -> LPVOID
# dwDesiredAccess : DWORD -> DWORD
# dwShareMode : DWORD -> DWORD
# dwCreationMode : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
文字セット違い
- f OpenColorProfileA (ANSI版) — カラープロファイルを開いてハンドルを取得する(ANSI版)。
使用する型