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

WcsSetDefaultColorProfile

関数
デバイスの既定WCSカラープロファイルを設定する。
DLLmscms.dll呼出規約winapi

シグネチャ

// mscms.dll
#include <windows.h>

BOOL WcsSetDefaultColorProfile(
    WCS_PROFILE_MANAGEMENT_SCOPE scope,
    LPCWSTR pDeviceName,   // optional
    COLORPROFILETYPE cptColorProfileType,
    COLORPROFILESUBTYPE cpstColorProfileSubType,
    DWORD dwProfileID,
    LPCWSTR pProfileName   // optional
);

パラメーター

名前方向
scopeWCS_PROFILE_MANAGEMENT_SCOPEin
pDeviceNameLPCWSTRinoptional
cptColorProfileTypeCOLORPROFILETYPEin
cpstColorProfileSubTypeCOLORPROFILESUBTYPEin
dwProfileIDDWORDin
pProfileNameLPCWSTRinoptional

戻り値の型: BOOL

各言語での呼び出し定義

// mscms.dll
#include <windows.h>

BOOL WcsSetDefaultColorProfile(
    WCS_PROFILE_MANAGEMENT_SCOPE scope,
    LPCWSTR pDeviceName,   // optional
    COLORPROFILETYPE cptColorProfileType,
    COLORPROFILESUBTYPE cpstColorProfileSubType,
    DWORD dwProfileID,
    LPCWSTR pProfileName   // optional
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("mscms.dll", ExactSpelling = true)]
static extern bool WcsSetDefaultColorProfile(
    int scope,   // WCS_PROFILE_MANAGEMENT_SCOPE
    [MarshalAs(UnmanagedType.LPWStr)] string pDeviceName,   // LPCWSTR optional
    int cptColorProfileType,   // COLORPROFILETYPE
    int cpstColorProfileSubType,   // COLORPROFILESUBTYPE
    uint dwProfileID,   // DWORD
    [MarshalAs(UnmanagedType.LPWStr)] string pProfileName   // LPCWSTR optional
);
<DllImport("mscms.dll", ExactSpelling:=True)>
Public Shared Function WcsSetDefaultColorProfile(
    scope As Integer,   ' WCS_PROFILE_MANAGEMENT_SCOPE
    <MarshalAs(UnmanagedType.LPWStr)> pDeviceName As String,   ' LPCWSTR optional
    cptColorProfileType As Integer,   ' COLORPROFILETYPE
    cpstColorProfileSubType As Integer,   ' COLORPROFILESUBTYPE
    dwProfileID As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPWStr)> pProfileName As String   ' LPCWSTR optional
) As Boolean
End Function
' scope : WCS_PROFILE_MANAGEMENT_SCOPE
' pDeviceName : LPCWSTR optional
' cptColorProfileType : COLORPROFILETYPE
' cpstColorProfileSubType : COLORPROFILESUBTYPE
' dwProfileID : DWORD
' pProfileName : LPCWSTR optional
Declare PtrSafe Function WcsSetDefaultColorProfile Lib "mscms" ( _
    ByVal scope As Long, _
    ByVal pDeviceName As LongPtr, _
    ByVal cptColorProfileType As Long, _
    ByVal cpstColorProfileSubType As Long, _
    ByVal dwProfileID As Long, _
    ByVal pProfileName As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WcsSetDefaultColorProfile = ctypes.windll.mscms.WcsSetDefaultColorProfile
WcsSetDefaultColorProfile.restype = wintypes.BOOL
WcsSetDefaultColorProfile.argtypes = [
    ctypes.c_int,  # scope : WCS_PROFILE_MANAGEMENT_SCOPE
    wintypes.LPCWSTR,  # pDeviceName : LPCWSTR optional
    ctypes.c_int,  # cptColorProfileType : COLORPROFILETYPE
    ctypes.c_int,  # cpstColorProfileSubType : COLORPROFILESUBTYPE
    wintypes.DWORD,  # dwProfileID : DWORD
    wintypes.LPCWSTR,  # pProfileName : LPCWSTR optional
]
require 'fiddle'
require 'fiddle/import'

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

var (
	mscms = windows.NewLazySystemDLL("mscms.dll")
	procWcsSetDefaultColorProfile = mscms.NewProc("WcsSetDefaultColorProfile")
)

// scope (WCS_PROFILE_MANAGEMENT_SCOPE), pDeviceName (LPCWSTR optional), cptColorProfileType (COLORPROFILETYPE), cpstColorProfileSubType (COLORPROFILESUBTYPE), dwProfileID (DWORD), pProfileName (LPCWSTR optional)
r1, _, err := procWcsSetDefaultColorProfile.Call(
	uintptr(scope),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pDeviceName))),
	uintptr(cptColorProfileType),
	uintptr(cpstColorProfileSubType),
	uintptr(dwProfileID),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pProfileName))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function WcsSetDefaultColorProfile(
  scope: Integer;   // WCS_PROFILE_MANAGEMENT_SCOPE
  pDeviceName: PWideChar;   // LPCWSTR optional
  cptColorProfileType: Integer;   // COLORPROFILETYPE
  cpstColorProfileSubType: Integer;   // COLORPROFILESUBTYPE
  dwProfileID: DWORD;   // DWORD
  pProfileName: PWideChar   // LPCWSTR optional
): BOOL; stdcall;
  external 'mscms.dll' name 'WcsSetDefaultColorProfile';
result := DllCall("mscms\WcsSetDefaultColorProfile"
    , "Int", scope   ; WCS_PROFILE_MANAGEMENT_SCOPE
    , "WStr", pDeviceName   ; LPCWSTR optional
    , "Int", cptColorProfileType   ; COLORPROFILETYPE
    , "Int", cpstColorProfileSubType   ; COLORPROFILESUBTYPE
    , "UInt", dwProfileID   ; DWORD
    , "WStr", pProfileName   ; LPCWSTR optional
    , "Int")   ; return: BOOL
●WcsSetDefaultColorProfile(scope, pDeviceName, cptColorProfileType, cpstColorProfileSubType, dwProfileID, pProfileName) = DLL("mscms.dll", "bool WcsSetDefaultColorProfile(int, char*, int, int, dword, char*)")
# 呼び出し: WcsSetDefaultColorProfile(scope, pDeviceName, cptColorProfileType, cpstColorProfileSubType, dwProfileID, pProfileName)
# scope : WCS_PROFILE_MANAGEMENT_SCOPE -> "int"
# pDeviceName : LPCWSTR optional -> "char*"
# cptColorProfileType : COLORPROFILETYPE -> "int"
# cpstColorProfileSubType : COLORPROFILESUBTYPE -> "int"
# dwProfileID : DWORD -> "dword"
# pProfileName : LPCWSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。