ホーム › UI.ColorSystem › ColorProfileAddDisplayAssociation
ColorProfileAddDisplayAssociation
関数カラープロファイルを指定ディスプレイに関連付ける。
シグネチャ
// mscms.dll
#include <windows.h>
HRESULT ColorProfileAddDisplayAssociation(
WCS_PROFILE_MANAGEMENT_SCOPE scope,
LPCWSTR profileName,
LUID targetAdapterID,
DWORD sourceID,
BOOL setAsDefault,
BOOL associateAsAdvancedColor
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| scope | WCS_PROFILE_MANAGEMENT_SCOPE | in |
| profileName | LPCWSTR | in |
| targetAdapterID | LUID | in |
| sourceID | DWORD | in |
| setAsDefault | BOOL | in |
| associateAsAdvancedColor | BOOL | in |
戻り値の型: HRESULT
各言語での呼び出し定義
// mscms.dll
#include <windows.h>
HRESULT ColorProfileAddDisplayAssociation(
WCS_PROFILE_MANAGEMENT_SCOPE scope,
LPCWSTR profileName,
LUID targetAdapterID,
DWORD sourceID,
BOOL setAsDefault,
BOOL associateAsAdvancedColor
);[DllImport("mscms.dll", ExactSpelling = true)]
static extern int ColorProfileAddDisplayAssociation(
int scope, // WCS_PROFILE_MANAGEMENT_SCOPE
[MarshalAs(UnmanagedType.LPWStr)] string profileName, // LPCWSTR
LUID targetAdapterID, // LUID
uint sourceID, // DWORD
bool setAsDefault, // BOOL
bool associateAsAdvancedColor // BOOL
);<DllImport("mscms.dll", ExactSpelling:=True)>
Public Shared Function ColorProfileAddDisplayAssociation(
scope As Integer, ' WCS_PROFILE_MANAGEMENT_SCOPE
<MarshalAs(UnmanagedType.LPWStr)> profileName As String, ' LPCWSTR
targetAdapterID As LUID, ' LUID
sourceID As UInteger, ' DWORD
setAsDefault As Boolean, ' BOOL
associateAsAdvancedColor As Boolean ' BOOL
) As Integer
End Function' scope : WCS_PROFILE_MANAGEMENT_SCOPE
' profileName : LPCWSTR
' targetAdapterID : LUID
' sourceID : DWORD
' setAsDefault : BOOL
' associateAsAdvancedColor : BOOL
Declare PtrSafe Function ColorProfileAddDisplayAssociation Lib "mscms" ( _
ByVal scope As Long, _
ByVal profileName As LongPtr, _
ByVal targetAdapterID As LongPtr, _
ByVal sourceID As Long, _
ByVal setAsDefault As Long, _
ByVal associateAsAdvancedColor As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ColorProfileAddDisplayAssociation = ctypes.windll.mscms.ColorProfileAddDisplayAssociation
ColorProfileAddDisplayAssociation.restype = ctypes.c_int
ColorProfileAddDisplayAssociation.argtypes = [
ctypes.c_int, # scope : WCS_PROFILE_MANAGEMENT_SCOPE
wintypes.LPCWSTR, # profileName : LPCWSTR
LUID, # targetAdapterID : LUID
wintypes.DWORD, # sourceID : DWORD
wintypes.BOOL, # setAsDefault : BOOL
wintypes.BOOL, # associateAsAdvancedColor : BOOL
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('mscms.dll')
ColorProfileAddDisplayAssociation = Fiddle::Function.new(
lib['ColorProfileAddDisplayAssociation'],
[
Fiddle::TYPE_INT, # scope : WCS_PROFILE_MANAGEMENT_SCOPE
Fiddle::TYPE_VOIDP, # profileName : LPCWSTR
Fiddle::TYPE_VOIDP, # targetAdapterID : LUID
-Fiddle::TYPE_INT, # sourceID : DWORD
Fiddle::TYPE_INT, # setAsDefault : BOOL
Fiddle::TYPE_INT, # associateAsAdvancedColor : BOOL
],
Fiddle::TYPE_INT)#[link(name = "mscms")]
extern "system" {
fn ColorProfileAddDisplayAssociation(
scope: i32, // WCS_PROFILE_MANAGEMENT_SCOPE
profileName: *const u16, // LPCWSTR
targetAdapterID: LUID, // LUID
sourceID: u32, // DWORD
setAsDefault: i32, // BOOL
associateAsAdvancedColor: i32 // BOOL
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("mscms.dll")]
public static extern int ColorProfileAddDisplayAssociation(int scope, [MarshalAs(UnmanagedType.LPWStr)] string profileName, LUID targetAdapterID, uint sourceID, bool setAsDefault, bool associateAsAdvancedColor);
"@
$api = Add-Type -MemberDefinition $sig -Name 'mscms_ColorProfileAddDisplayAssociation' -Namespace Win32 -PassThru
# $api::ColorProfileAddDisplayAssociation(scope, profileName, targetAdapterID, sourceID, setAsDefault, associateAsAdvancedColor)#uselib "mscms.dll"
#func global ColorProfileAddDisplayAssociation "ColorProfileAddDisplayAssociation" sptr, sptr, sptr, sptr, sptr, sptr
; ColorProfileAddDisplayAssociation scope, profileName, targetAdapterID, sourceID, setAsDefault, associateAsAdvancedColor ; 戻り値は stat
; scope : WCS_PROFILE_MANAGEMENT_SCOPE -> "sptr"
; profileName : LPCWSTR -> "sptr"
; targetAdapterID : LUID -> "sptr"
; sourceID : DWORD -> "sptr"
; setAsDefault : BOOL -> "sptr"
; associateAsAdvancedColor : BOOL -> "sptr"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "mscms.dll"
#cfunc global ColorProfileAddDisplayAssociation "ColorProfileAddDisplayAssociation" int, wstr, int, int, int, int
; res = ColorProfileAddDisplayAssociation(scope, profileName, targetAdapterID, sourceID, setAsDefault, associateAsAdvancedColor)
; scope : WCS_PROFILE_MANAGEMENT_SCOPE -> "int"
; profileName : LPCWSTR -> "wstr"
; targetAdapterID : LUID -> "int"
; sourceID : DWORD -> "int"
; setAsDefault : BOOL -> "int"
; associateAsAdvancedColor : BOOL -> "int"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。; HRESULT ColorProfileAddDisplayAssociation(WCS_PROFILE_MANAGEMENT_SCOPE scope, LPCWSTR profileName, LUID targetAdapterID, DWORD sourceID, BOOL setAsDefault, BOOL associateAsAdvancedColor)
#uselib "mscms.dll"
#cfunc global ColorProfileAddDisplayAssociation "ColorProfileAddDisplayAssociation" int, wstr, int, int, int, int
; res = ColorProfileAddDisplayAssociation(scope, profileName, targetAdapterID, sourceID, setAsDefault, associateAsAdvancedColor)
; scope : WCS_PROFILE_MANAGEMENT_SCOPE -> "int"
; profileName : LPCWSTR -> "wstr"
; targetAdapterID : LUID -> "int"
; sourceID : DWORD -> "int"
; setAsDefault : BOOL -> "int"
; associateAsAdvancedColor : BOOL -> "int"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
mscms = windows.NewLazySystemDLL("mscms.dll")
procColorProfileAddDisplayAssociation = mscms.NewProc("ColorProfileAddDisplayAssociation")
)
// scope (WCS_PROFILE_MANAGEMENT_SCOPE), profileName (LPCWSTR), targetAdapterID (LUID), sourceID (DWORD), setAsDefault (BOOL), associateAsAdvancedColor (BOOL)
r1, _, err := procColorProfileAddDisplayAssociation.Call(
uintptr(scope),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(profileName))),
uintptr(targetAdapterID),
uintptr(sourceID),
uintptr(setAsDefault),
uintptr(associateAsAdvancedColor),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction ColorProfileAddDisplayAssociation(
scope: Integer; // WCS_PROFILE_MANAGEMENT_SCOPE
profileName: PWideChar; // LPCWSTR
targetAdapterID: LUID; // LUID
sourceID: DWORD; // DWORD
setAsDefault: BOOL; // BOOL
associateAsAdvancedColor: BOOL // BOOL
): Integer; stdcall;
external 'mscms.dll' name 'ColorProfileAddDisplayAssociation';result := DllCall("mscms\ColorProfileAddDisplayAssociation"
, "Int", scope ; WCS_PROFILE_MANAGEMENT_SCOPE
, "WStr", profileName ; LPCWSTR
, "Ptr", targetAdapterID ; LUID
, "UInt", sourceID ; DWORD
, "Int", setAsDefault ; BOOL
, "Int", associateAsAdvancedColor ; BOOL
, "Int") ; return: HRESULT●ColorProfileAddDisplayAssociation(scope, profileName, targetAdapterID, sourceID, setAsDefault, associateAsAdvancedColor) = DLL("mscms.dll", "int ColorProfileAddDisplayAssociation(int, char*, void*, dword, bool, bool)")
# 呼び出し: ColorProfileAddDisplayAssociation(scope, profileName, targetAdapterID, sourceID, setAsDefault, associateAsAdvancedColor)
# scope : WCS_PROFILE_MANAGEMENT_SCOPE -> "int"
# profileName : LPCWSTR -> "char*"
# targetAdapterID : LUID -> "void*"
# sourceID : DWORD -> "dword"
# setAsDefault : BOOL -> "bool"
# associateAsAdvancedColor : BOOL -> "bool"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。