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

OpenColorProfileA

関数
カラープロファイルを開いてハンドルを取得する(ANSI版)。
DLLmscms.dll文字セットANSI (-A)呼出規約winapi

シグネチャ

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

INT_PTR OpenColorProfileA(
    PROFILE* pProfile,
    DWORD dwDesiredAccess,
    DWORD dwShareMode,
    DWORD dwCreationMode
);

パラメーター

名前方向
pProfilePROFILE*in
dwDesiredAccessDWORDin
dwShareModeDWORDin
dwCreationModeDWORDin

戻り値の型: 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 方式にも切替可。
出力引数:
; 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 方式にも切替可。
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_PTR
function 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)。