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

InstallColorProfileW

関数
カラープロファイルをシステムに導入する(Unicode版)。
DLLmscms.dll文字セットUnicode (-W)呼出規約winapi

シグネチャ

// mscms.dll  (Unicode / -W)
#include <windows.h>

BOOL InstallColorProfileW(
    LPCWSTR pMachineName,   // optional
    LPCWSTR pProfileName
);

パラメーター

名前方向
pMachineNameLPCWSTRinoptional
pProfileNameLPCWSTRin

戻り値の型: BOOL

各言語での呼び出し定義

// mscms.dll  (Unicode / -W)
#include <windows.h>

BOOL InstallColorProfileW(
    LPCWSTR pMachineName,   // optional
    LPCWSTR pProfileName
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("mscms.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern bool InstallColorProfileW(
    [MarshalAs(UnmanagedType.LPWStr)] string pMachineName,   // LPCWSTR optional
    [MarshalAs(UnmanagedType.LPWStr)] string pProfileName   // LPCWSTR
);
<DllImport("mscms.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function InstallColorProfileW(
    <MarshalAs(UnmanagedType.LPWStr)> pMachineName As String,   ' LPCWSTR optional
    <MarshalAs(UnmanagedType.LPWStr)> pProfileName As String   ' LPCWSTR
) As Boolean
End Function
' pMachineName : LPCWSTR optional
' pProfileName : LPCWSTR
Declare PtrSafe Function InstallColorProfileW Lib "mscms" ( _
    ByVal pMachineName As LongPtr, _
    ByVal pProfileName As LongPtr) As Long
' 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

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

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

var (
	mscms = windows.NewLazySystemDLL("mscms.dll")
	procInstallColorProfileW = mscms.NewProc("InstallColorProfileW")
)

// pMachineName (LPCWSTR optional), pProfileName (LPCWSTR)
r1, _, err := procInstallColorProfileW.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pMachineName))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pProfileName))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function InstallColorProfileW(
  pMachineName: PWideChar;   // LPCWSTR optional
  pProfileName: PWideChar   // LPCWSTR
): BOOL; stdcall;
  external 'mscms.dll' name 'InstallColorProfileW';
result := DllCall("mscms\InstallColorProfileW"
    , "WStr", pMachineName   ; LPCWSTR optional
    , "WStr", pProfileName   ; LPCWSTR
    , "Int")   ; return: BOOL
●InstallColorProfileW(pMachineName, pProfileName) = DLL("mscms.dll", "bool InstallColorProfileW(char*, char*)")
# 呼び出し: InstallColorProfileW(pMachineName, pProfileName)
# pMachineName : LPCWSTR optional -> "char*"
# pProfileName : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。