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
pProfileNameLPCSTRin
pDeviceNameLPCSTRin

戻り値の型: 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 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)。