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

ColorProfileSetDisplayDefaultAssociation

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

シグネチャ

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

HRESULT ColorProfileSetDisplayDefaultAssociation(
    WCS_PROFILE_MANAGEMENT_SCOPE scope,
    LPCWSTR profileName,
    COLORPROFILETYPE profileType,
    COLORPROFILESUBTYPE profileSubType,
    LUID targetAdapterID,
    DWORD sourceID
);

パラメーター

名前方向
scopeWCS_PROFILE_MANAGEMENT_SCOPEin
profileNameLPCWSTRin
profileTypeCOLORPROFILETYPEin
profileSubTypeCOLORPROFILESUBTYPEin
targetAdapterIDLUIDin
sourceIDDWORDin

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT ColorProfileSetDisplayDefaultAssociation(
    WCS_PROFILE_MANAGEMENT_SCOPE scope,
    LPCWSTR profileName,
    COLORPROFILETYPE profileType,
    COLORPROFILESUBTYPE profileSubType,
    LUID targetAdapterID,
    DWORD sourceID
);
[DllImport("mscms.dll", ExactSpelling = true)]
static extern int ColorProfileSetDisplayDefaultAssociation(
    int scope,   // WCS_PROFILE_MANAGEMENT_SCOPE
    [MarshalAs(UnmanagedType.LPWStr)] string profileName,   // LPCWSTR
    int profileType,   // COLORPROFILETYPE
    int profileSubType,   // COLORPROFILESUBTYPE
    LUID targetAdapterID,   // LUID
    uint sourceID   // DWORD
);
<DllImport("mscms.dll", ExactSpelling:=True)>
Public Shared Function ColorProfileSetDisplayDefaultAssociation(
    scope As Integer,   ' WCS_PROFILE_MANAGEMENT_SCOPE
    <MarshalAs(UnmanagedType.LPWStr)> profileName As String,   ' LPCWSTR
    profileType As Integer,   ' COLORPROFILETYPE
    profileSubType As Integer,   ' COLORPROFILESUBTYPE
    targetAdapterID As LUID,   ' LUID
    sourceID As UInteger   ' DWORD
) As Integer
End Function
' scope : WCS_PROFILE_MANAGEMENT_SCOPE
' profileName : LPCWSTR
' profileType : COLORPROFILETYPE
' profileSubType : COLORPROFILESUBTYPE
' targetAdapterID : LUID
' sourceID : DWORD
Declare PtrSafe Function ColorProfileSetDisplayDefaultAssociation Lib "mscms" ( _
    ByVal scope As Long, _
    ByVal profileName As LongPtr, _
    ByVal profileType As Long, _
    ByVal profileSubType As Long, _
    ByVal targetAdapterID As LongPtr, _
    ByVal sourceID As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ColorProfileSetDisplayDefaultAssociation = ctypes.windll.mscms.ColorProfileSetDisplayDefaultAssociation
ColorProfileSetDisplayDefaultAssociation.restype = ctypes.c_int
ColorProfileSetDisplayDefaultAssociation.argtypes = [
    ctypes.c_int,  # scope : WCS_PROFILE_MANAGEMENT_SCOPE
    wintypes.LPCWSTR,  # profileName : LPCWSTR
    ctypes.c_int,  # profileType : COLORPROFILETYPE
    ctypes.c_int,  # profileSubType : COLORPROFILESUBTYPE
    LUID,  # targetAdapterID : LUID
    wintypes.DWORD,  # sourceID : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('mscms.dll')
ColorProfileSetDisplayDefaultAssociation = Fiddle::Function.new(
  lib['ColorProfileSetDisplayDefaultAssociation'],
  [
    Fiddle::TYPE_INT,  # scope : WCS_PROFILE_MANAGEMENT_SCOPE
    Fiddle::TYPE_VOIDP,  # profileName : LPCWSTR
    Fiddle::TYPE_INT,  # profileType : COLORPROFILETYPE
    Fiddle::TYPE_INT,  # profileSubType : COLORPROFILESUBTYPE
    Fiddle::TYPE_VOIDP,  # targetAdapterID : LUID
    -Fiddle::TYPE_INT,  # sourceID : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "mscms")]
extern "system" {
    fn ColorProfileSetDisplayDefaultAssociation(
        scope: i32,  // WCS_PROFILE_MANAGEMENT_SCOPE
        profileName: *const u16,  // LPCWSTR
        profileType: i32,  // COLORPROFILETYPE
        profileSubType: i32,  // COLORPROFILESUBTYPE
        targetAdapterID: LUID,  // LUID
        sourceID: u32  // DWORD
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("mscms.dll")]
public static extern int ColorProfileSetDisplayDefaultAssociation(int scope, [MarshalAs(UnmanagedType.LPWStr)] string profileName, int profileType, int profileSubType, LUID targetAdapterID, uint sourceID);
"@
$api = Add-Type -MemberDefinition $sig -Name 'mscms_ColorProfileSetDisplayDefaultAssociation' -Namespace Win32 -PassThru
# $api::ColorProfileSetDisplayDefaultAssociation(scope, profileName, profileType, profileSubType, targetAdapterID, sourceID)
#uselib "mscms.dll"
#func global ColorProfileSetDisplayDefaultAssociation "ColorProfileSetDisplayDefaultAssociation" sptr, sptr, sptr, sptr, sptr, sptr
; ColorProfileSetDisplayDefaultAssociation scope, profileName, profileType, profileSubType, targetAdapterID, sourceID   ; 戻り値は stat
; scope : WCS_PROFILE_MANAGEMENT_SCOPE -> "sptr"
; profileName : LPCWSTR -> "sptr"
; profileType : COLORPROFILETYPE -> "sptr"
; profileSubType : COLORPROFILESUBTYPE -> "sptr"
; targetAdapterID : LUID -> "sptr"
; sourceID : DWORD -> "sptr"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "mscms.dll"
#cfunc global ColorProfileSetDisplayDefaultAssociation "ColorProfileSetDisplayDefaultAssociation" int, wstr, int, int, int, int
; res = ColorProfileSetDisplayDefaultAssociation(scope, profileName, profileType, profileSubType, targetAdapterID, sourceID)
; scope : WCS_PROFILE_MANAGEMENT_SCOPE -> "int"
; profileName : LPCWSTR -> "wstr"
; profileType : COLORPROFILETYPE -> "int"
; profileSubType : COLORPROFILESUBTYPE -> "int"
; targetAdapterID : LUID -> "int"
; sourceID : DWORD -> "int"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
; HRESULT ColorProfileSetDisplayDefaultAssociation(WCS_PROFILE_MANAGEMENT_SCOPE scope, LPCWSTR profileName, COLORPROFILETYPE profileType, COLORPROFILESUBTYPE profileSubType, LUID targetAdapterID, DWORD sourceID)
#uselib "mscms.dll"
#cfunc global ColorProfileSetDisplayDefaultAssociation "ColorProfileSetDisplayDefaultAssociation" int, wstr, int, int, int, int
; res = ColorProfileSetDisplayDefaultAssociation(scope, profileName, profileType, profileSubType, targetAdapterID, sourceID)
; scope : WCS_PROFILE_MANAGEMENT_SCOPE -> "int"
; profileName : LPCWSTR -> "wstr"
; profileType : COLORPROFILETYPE -> "int"
; profileSubType : COLORPROFILESUBTYPE -> "int"
; targetAdapterID : LUID -> "int"
; sourceID : DWORD -> "int"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	mscms = windows.NewLazySystemDLL("mscms.dll")
	procColorProfileSetDisplayDefaultAssociation = mscms.NewProc("ColorProfileSetDisplayDefaultAssociation")
)

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