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

AssociateColorProfileWithDeviceA

関数
カラープロファイルをデバイスに関連付ける(ANSI版)。
DLLmscms.dll文字セットANSI (-A)呼出規約winapi

シグネチャ

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

BOOL AssociateColorProfileWithDeviceA(
    LPCSTR pMachineName,   // optional
    LPCSTR pProfileName,
    LPCSTR pDeviceName
);

パラメーター

名前方向説明
pMachineNameLPCSTRinoptional対象マシン名を指すANSI文字列ポインタ。ローカルではNULLを指定する。
pProfileNameLPCSTRinデバイスに関連付けるカラープロファイル名を指すANSI文字列ポインタ。
pDeviceNameLPCSTRinプロファイルを関連付ける対象デバイス名を指すANSI文字列ポインタ。

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL AssociateColorProfileWithDeviceA(
    LPCSTR pMachineName,   // optional
    LPCSTR pProfileName,
    LPCSTR pDeviceName
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("mscms.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern bool AssociateColorProfileWithDeviceA(
    [MarshalAs(UnmanagedType.LPStr)] string pMachineName,   // LPCSTR optional
    [MarshalAs(UnmanagedType.LPStr)] string pProfileName,   // LPCSTR
    [MarshalAs(UnmanagedType.LPStr)] string pDeviceName   // LPCSTR
);
<DllImport("mscms.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function AssociateColorProfileWithDeviceA(
    <MarshalAs(UnmanagedType.LPStr)> pMachineName As String,   ' LPCSTR optional
    <MarshalAs(UnmanagedType.LPStr)> pProfileName As String,   ' LPCSTR
    <MarshalAs(UnmanagedType.LPStr)> pDeviceName As String   ' LPCSTR
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
' pMachineName : LPCSTR optional
' pProfileName : LPCSTR
' pDeviceName : LPCSTR
Declare PtrSafe Function AssociateColorProfileWithDeviceA Lib "mscms" ( _
    ByVal pMachineName As String, _
    ByVal pProfileName As String, _
    ByVal pDeviceName As String) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

AssociateColorProfileWithDeviceA = ctypes.windll.mscms.AssociateColorProfileWithDeviceA
AssociateColorProfileWithDeviceA.restype = wintypes.BOOL
AssociateColorProfileWithDeviceA.argtypes = [
    wintypes.LPCSTR,  # pMachineName : LPCSTR optional
    wintypes.LPCSTR,  # pProfileName : LPCSTR
    wintypes.LPCSTR,  # pDeviceName : LPCSTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('mscms.dll')
AssociateColorProfileWithDeviceA = Fiddle::Function.new(
  lib['AssociateColorProfileWithDeviceA'],
  [
    Fiddle::TYPE_VOIDP,  # pMachineName : LPCSTR optional
    Fiddle::TYPE_VOIDP,  # pProfileName : LPCSTR
    Fiddle::TYPE_VOIDP,  # pDeviceName : LPCSTR
  ],
  Fiddle::TYPE_INT)
#[link(name = "mscms")]
extern "system" {
    fn AssociateColorProfileWithDeviceA(
        pMachineName: *const u8,  // LPCSTR optional
        pProfileName: *const u8,  // LPCSTR
        pDeviceName: *const u8  // LPCSTR
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("mscms.dll", CharSet = CharSet.Ansi)]
public static extern bool AssociateColorProfileWithDeviceA([MarshalAs(UnmanagedType.LPStr)] string pMachineName, [MarshalAs(UnmanagedType.LPStr)] string pProfileName, [MarshalAs(UnmanagedType.LPStr)] string pDeviceName);
"@
$api = Add-Type -MemberDefinition $sig -Name 'mscms_AssociateColorProfileWithDeviceA' -Namespace Win32 -PassThru
# $api::AssociateColorProfileWithDeviceA(pMachineName, pProfileName, pDeviceName)
#uselib "mscms.dll"
#func global AssociateColorProfileWithDeviceA "AssociateColorProfileWithDeviceA" sptr, sptr, sptr
; AssociateColorProfileWithDeviceA pMachineName, pProfileName, pDeviceName   ; 戻り値は stat
; pMachineName : LPCSTR optional -> "sptr"
; pProfileName : LPCSTR -> "sptr"
; pDeviceName : LPCSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "mscms.dll"
#cfunc global AssociateColorProfileWithDeviceA "AssociateColorProfileWithDeviceA" str, str, str
; res = AssociateColorProfileWithDeviceA(pMachineName, pProfileName, pDeviceName)
; pMachineName : LPCSTR optional -> "str"
; pProfileName : LPCSTR -> "str"
; pDeviceName : LPCSTR -> "str"
; BOOL AssociateColorProfileWithDeviceA(LPCSTR pMachineName, LPCSTR pProfileName, LPCSTR pDeviceName)
#uselib "mscms.dll"
#cfunc global AssociateColorProfileWithDeviceA "AssociateColorProfileWithDeviceA" str, str, str
; res = AssociateColorProfileWithDeviceA(pMachineName, pProfileName, pDeviceName)
; pMachineName : LPCSTR optional -> "str"
; pProfileName : LPCSTR -> "str"
; pDeviceName : LPCSTR -> "str"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	mscms = windows.NewLazySystemDLL("mscms.dll")
	procAssociateColorProfileWithDeviceA = mscms.NewProc("AssociateColorProfileWithDeviceA")
)

// pMachineName (LPCSTR optional), pProfileName (LPCSTR), pDeviceName (LPCSTR)
r1, _, err := procAssociateColorProfileWithDeviceA.Call(
	uintptr(unsafe.Pointer(windows.BytePtrFromString(pMachineName))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(pProfileName))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(pDeviceName))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function AssociateColorProfileWithDeviceA(
  pMachineName: PAnsiChar;   // LPCSTR optional
  pProfileName: PAnsiChar;   // LPCSTR
  pDeviceName: PAnsiChar   // LPCSTR
): BOOL; stdcall;
  external 'mscms.dll' name 'AssociateColorProfileWithDeviceA';
result := DllCall("mscms\AssociateColorProfileWithDeviceA"
    , "AStr", pMachineName   ; LPCSTR optional
    , "AStr", pProfileName   ; LPCSTR
    , "AStr", pDeviceName   ; LPCSTR
    , "Int")   ; return: BOOL
●AssociateColorProfileWithDeviceA(pMachineName, pProfileName, pDeviceName) = DLL("mscms.dll", "bool AssociateColorProfileWithDeviceA(char*, char*, char*)")
# 呼び出し: AssociateColorProfileWithDeviceA(pMachineName, pProfileName, pDeviceName)
# pMachineName : LPCSTR optional -> "char*"
# pProfileName : LPCSTR -> "char*"
# pDeviceName : LPCSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "mscms" fn AssociateColorProfileWithDeviceA(
    pMachineName: [*c]const u8, // LPCSTR optional
    pProfileName: [*c]const u8, // LPCSTR
    pDeviceName: [*c]const u8 // LPCSTR
) callconv(std.os.windows.WINAPI) i32;
proc AssociateColorProfileWithDeviceA(
    pMachineName: cstring,  # LPCSTR optional
    pProfileName: cstring,  # LPCSTR
    pDeviceName: cstring  # LPCSTR
): int32 {.importc: "AssociateColorProfileWithDeviceA", stdcall, dynlib: "mscms.dll".}
pragma(lib, "mscms");
extern(Windows)
int AssociateColorProfileWithDeviceA(
    const(char)* pMachineName,   // LPCSTR optional
    const(char)* pProfileName,   // LPCSTR
    const(char)* pDeviceName   // LPCSTR
);
ccall((:AssociateColorProfileWithDeviceA, "mscms.dll"), stdcall, Int32,
      (Cstring, Cstring, Cstring),
      pMachineName, pProfileName, pDeviceName)
# pMachineName : LPCSTR optional -> Cstring
# pProfileName : LPCSTR -> Cstring
# pDeviceName : LPCSTR -> Cstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t AssociateColorProfileWithDeviceA(
    const char* pMachineName,
    const char* pProfileName,
    const char* pDeviceName);
]]
local mscms = ffi.load("mscms")
-- mscms.AssociateColorProfileWithDeviceA(pMachineName, pProfileName, pDeviceName)
-- pMachineName : LPCSTR optional
-- pProfileName : LPCSTR
-- pDeviceName : LPCSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('mscms.dll');
const AssociateColorProfileWithDeviceA = lib.func('__stdcall', 'AssociateColorProfileWithDeviceA', 'int32_t', ['str', 'str', 'str']);
// AssociateColorProfileWithDeviceA(pMachineName, pProfileName, pDeviceName)
// pMachineName : LPCSTR optional -> 'str'
// pProfileName : LPCSTR -> 'str'
// pDeviceName : LPCSTR -> 'str'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("mscms.dll", {
  AssociateColorProfileWithDeviceA: { parameters: ["buffer", "buffer", "buffer"], result: "i32" },
});
// lib.symbols.AssociateColorProfileWithDeviceA(pMachineName, pProfileName, pDeviceName)
// pMachineName : LPCSTR optional -> "buffer"
// pProfileName : LPCSTR -> "buffer"
// pDeviceName : LPCSTR -> "buffer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t AssociateColorProfileWithDeviceA(
    const char* pMachineName,
    const char* pProfileName,
    const char* pDeviceName);
C, "mscms.dll");
// $ffi->AssociateColorProfileWithDeviceA(pMachineName, pProfileName, pDeviceName);
// pMachineName : LPCSTR optional
// pProfileName : LPCSTR
// pDeviceName : LPCSTR
// 構造体/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);
    boolean AssociateColorProfileWithDeviceA(
        String pMachineName,   // LPCSTR optional
        String pProfileName,   // LPCSTR
        String pDeviceName   // LPCSTR
    );
}
@[Link("mscms")]
lib Libmscms
  fun AssociateColorProfileWithDeviceA = AssociateColorProfileWithDeviceA(
    pMachineName : UInt8*,   # LPCSTR optional
    pProfileName : UInt8*,   # LPCSTR
    pDeviceName : UInt8*   # LPCSTR
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef AssociateColorProfileWithDeviceANative = Int32 Function(Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>);
typedef AssociateColorProfileWithDeviceADart = int Function(Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>);
final AssociateColorProfileWithDeviceA = DynamicLibrary.open('mscms.dll')
    .lookupFunction<AssociateColorProfileWithDeviceANative, AssociateColorProfileWithDeviceADart>('AssociateColorProfileWithDeviceA');
// pMachineName : LPCSTR optional -> Pointer<Utf8>
// pProfileName : LPCSTR -> Pointer<Utf8>
// pDeviceName : LPCSTR -> Pointer<Utf8>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function AssociateColorProfileWithDeviceA(
  pMachineName: PAnsiChar;   // LPCSTR optional
  pProfileName: PAnsiChar;   // LPCSTR
  pDeviceName: PAnsiChar   // LPCSTR
): BOOL; stdcall;
  external 'mscms.dll' name 'AssociateColorProfileWithDeviceA';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "AssociateColorProfileWithDeviceA"
  c_AssociateColorProfileWithDeviceA :: CString -> CString -> CString -> IO CInt
-- pMachineName : LPCSTR optional -> CString
-- pProfileName : LPCSTR -> CString
-- pDeviceName : LPCSTR -> CString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let associatecolorprofilewithdevicea =
  foreign "AssociateColorProfileWithDeviceA"
    (string @-> string @-> string @-> returning int32_t)
(* pMachineName : LPCSTR optional -> string *)
(* pProfileName : LPCSTR -> string *)
(* pDeviceName : LPCSTR -> string *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library mscms (t "mscms.dll"))
(cffi:use-foreign-library mscms)

(cffi:defcfun ("AssociateColorProfileWithDeviceA" associate-color-profile-with-device-a :convention :stdcall) :int32
  (p-machine-name :string)   ; LPCSTR optional
  (p-profile-name :string)   ; LPCSTR
  (p-device-name :string))   ; LPCSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $AssociateColorProfileWithDeviceA = Win32::API::More->new('mscms',
    'BOOL AssociateColorProfileWithDeviceA(LPCSTR pMachineName, LPCSTR pProfileName, LPCSTR pDeviceName)');
# my $ret = $AssociateColorProfileWithDeviceA->Call($pMachineName, $pProfileName, $pDeviceName);
# pMachineName : LPCSTR optional -> LPCSTR
# pProfileName : LPCSTR -> LPCSTR
# pDeviceName : LPCSTR -> LPCSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

文字セット違い