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

ColorProfileGetDisplayList

関数
ディスプレイに関連付けられたプロファイル一覧を取得する。
DLLmscms.dll呼出規約winapi

シグネチャ

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

HRESULT ColorProfileGetDisplayList(
    WCS_PROFILE_MANAGEMENT_SCOPE scope,
    LUID targetAdapterID,
    DWORD sourceID,
    LPWSTR** profileList,
    DWORD* profileCount
);

パラメーター

名前方向説明
scopeWCS_PROFILE_MANAGEMENT_SCOPEin対象の管理範囲(システム全体/現在ユーザー)を示すWCSスコープ列挙値。
targetAdapterIDLUIDin対象ディスプレイのアダプタを識別するLUID値。
sourceIDDWORDinアダプタ上の対象ソース(出力)を識別するID。
profileListLPWSTR**out関連付けられたプロファイル名配列のアドレスを受け取るポインタ。解放が必要。
profileCountDWORD*outリスト内のプロファイル数を受け取るDWORDへのポインタ。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT ColorProfileGetDisplayList(
    WCS_PROFILE_MANAGEMENT_SCOPE scope,
    LUID targetAdapterID,
    DWORD sourceID,
    LPWSTR** profileList,
    DWORD* profileCount
);
[DllImport("mscms.dll", ExactSpelling = true)]
static extern int ColorProfileGetDisplayList(
    int scope,   // WCS_PROFILE_MANAGEMENT_SCOPE
    LUID targetAdapterID,   // LUID
    uint sourceID,   // DWORD
    IntPtr profileList,   // LPWSTR** out
    out uint profileCount   // DWORD* out
);
<DllImport("mscms.dll", ExactSpelling:=True)>
Public Shared Function ColorProfileGetDisplayList(
    scope As Integer,   ' WCS_PROFILE_MANAGEMENT_SCOPE
    targetAdapterID As LUID,   ' LUID
    sourceID As UInteger,   ' DWORD
    profileList As IntPtr,   ' LPWSTR** out
    <Out> ByRef profileCount As UInteger   ' DWORD* out
) As Integer
End Function
' scope : WCS_PROFILE_MANAGEMENT_SCOPE
' targetAdapterID : LUID
' sourceID : DWORD
' profileList : LPWSTR** out
' profileCount : DWORD* out
Declare PtrSafe Function ColorProfileGetDisplayList Lib "mscms" ( _
    ByVal scope As Long, _
    ByVal targetAdapterID As LongPtr, _
    ByVal sourceID As Long, _
    ByVal profileList As LongPtr, _
    ByRef profileCount As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ColorProfileGetDisplayList = ctypes.windll.mscms.ColorProfileGetDisplayList
ColorProfileGetDisplayList.restype = ctypes.c_int
ColorProfileGetDisplayList.argtypes = [
    ctypes.c_int,  # scope : WCS_PROFILE_MANAGEMENT_SCOPE
    LUID,  # targetAdapterID : LUID
    wintypes.DWORD,  # sourceID : DWORD
    ctypes.c_void_p,  # profileList : LPWSTR** out
    ctypes.POINTER(wintypes.DWORD),  # profileCount : DWORD* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('mscms.dll')
ColorProfileGetDisplayList = Fiddle::Function.new(
  lib['ColorProfileGetDisplayList'],
  [
    Fiddle::TYPE_INT,  # scope : WCS_PROFILE_MANAGEMENT_SCOPE
    Fiddle::TYPE_VOIDP,  # targetAdapterID : LUID
    -Fiddle::TYPE_INT,  # sourceID : DWORD
    Fiddle::TYPE_VOIDP,  # profileList : LPWSTR** out
    Fiddle::TYPE_VOIDP,  # profileCount : DWORD* out
  ],
  Fiddle::TYPE_INT)
#[link(name = "mscms")]
extern "system" {
    fn ColorProfileGetDisplayList(
        scope: i32,  // WCS_PROFILE_MANAGEMENT_SCOPE
        targetAdapterID: LUID,  // LUID
        sourceID: u32,  // DWORD
        profileList: *mut *mut *mut u16,  // LPWSTR** out
        profileCount: *mut u32  // DWORD* out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("mscms.dll")]
public static extern int ColorProfileGetDisplayList(int scope, LUID targetAdapterID, uint sourceID, IntPtr profileList, out uint profileCount);
"@
$api = Add-Type -MemberDefinition $sig -Name 'mscms_ColorProfileGetDisplayList' -Namespace Win32 -PassThru
# $api::ColorProfileGetDisplayList(scope, targetAdapterID, sourceID, profileList, profileCount)
#uselib "mscms.dll"
#func global ColorProfileGetDisplayList "ColorProfileGetDisplayList" sptr, sptr, sptr, sptr, sptr
; ColorProfileGetDisplayList scope, targetAdapterID, sourceID, varptr(profileList), varptr(profileCount)   ; 戻り値は stat
; scope : WCS_PROFILE_MANAGEMENT_SCOPE -> "sptr"
; targetAdapterID : LUID -> "sptr"
; sourceID : DWORD -> "sptr"
; profileList : LPWSTR** out -> "sptr"
; profileCount : DWORD* out -> "sptr"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "mscms.dll"
#cfunc global ColorProfileGetDisplayList "ColorProfileGetDisplayList" int, int, int, var, var
; res = ColorProfileGetDisplayList(scope, targetAdapterID, sourceID, profileList, profileCount)
; scope : WCS_PROFILE_MANAGEMENT_SCOPE -> "int"
; targetAdapterID : LUID -> "int"
; sourceID : DWORD -> "int"
; profileList : LPWSTR** out -> "var"
; profileCount : DWORD* out -> "var"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT ColorProfileGetDisplayList(WCS_PROFILE_MANAGEMENT_SCOPE scope, LUID targetAdapterID, DWORD sourceID, LPWSTR** profileList, DWORD* profileCount)
#uselib "mscms.dll"
#cfunc global ColorProfileGetDisplayList "ColorProfileGetDisplayList" int, int, int, var, var
; res = ColorProfileGetDisplayList(scope, targetAdapterID, sourceID, profileList, profileCount)
; scope : WCS_PROFILE_MANAGEMENT_SCOPE -> "int"
; targetAdapterID : LUID -> "int"
; sourceID : DWORD -> "int"
; profileList : LPWSTR** out -> "var"
; profileCount : DWORD* out -> "var"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	mscms = windows.NewLazySystemDLL("mscms.dll")
	procColorProfileGetDisplayList = mscms.NewProc("ColorProfileGetDisplayList")
)

// scope (WCS_PROFILE_MANAGEMENT_SCOPE), targetAdapterID (LUID), sourceID (DWORD), profileList (LPWSTR** out), profileCount (DWORD* out)
r1, _, err := procColorProfileGetDisplayList.Call(
	uintptr(scope),
	uintptr(targetAdapterID),
	uintptr(sourceID),
	uintptr(profileList),
	uintptr(profileCount),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function ColorProfileGetDisplayList(
  scope: Integer;   // WCS_PROFILE_MANAGEMENT_SCOPE
  targetAdapterID: LUID;   // LUID
  sourceID: DWORD;   // DWORD
  profileList: PPWideChar;   // LPWSTR** out
  profileCount: Pointer   // DWORD* out
): Integer; stdcall;
  external 'mscms.dll' name 'ColorProfileGetDisplayList';
result := DllCall("mscms\ColorProfileGetDisplayList"
    , "Int", scope   ; WCS_PROFILE_MANAGEMENT_SCOPE
    , "Ptr", targetAdapterID   ; LUID
    , "UInt", sourceID   ; DWORD
    , "Ptr", profileList   ; LPWSTR** out
    , "Ptr", profileCount   ; DWORD* out
    , "Int")   ; return: HRESULT
●ColorProfileGetDisplayList(scope, targetAdapterID, sourceID, profileList, profileCount) = DLL("mscms.dll", "int ColorProfileGetDisplayList(int, void*, dword, void*, void*)")
# 呼び出し: ColorProfileGetDisplayList(scope, targetAdapterID, sourceID, profileList, profileCount)
# scope : WCS_PROFILE_MANAGEMENT_SCOPE -> "int"
# targetAdapterID : LUID -> "void*"
# sourceID : DWORD -> "dword"
# profileList : LPWSTR** out -> "void*"
# profileCount : DWORD* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "mscms" fn ColorProfileGetDisplayList(
    scope: i32, // WCS_PROFILE_MANAGEMENT_SCOPE
    targetAdapterID: LUID, // LUID
    sourceID: u32, // DWORD
    profileList: [*c][*c][*c]u16, // LPWSTR** out
    profileCount: [*c]u32 // DWORD* out
) callconv(std.os.windows.WINAPI) i32;
proc ColorProfileGetDisplayList(
    scope: int32,  # WCS_PROFILE_MANAGEMENT_SCOPE
    targetAdapterID: LUID,  # LUID
    sourceID: uint32,  # DWORD
    profileList: ptr WideCString,  # LPWSTR** out
    profileCount: ptr uint32  # DWORD* out
): int32 {.importc: "ColorProfileGetDisplayList", stdcall, dynlib: "mscms.dll".}
pragma(lib, "mscms");
extern(Windows)
int ColorProfileGetDisplayList(
    int scope,   // WCS_PROFILE_MANAGEMENT_SCOPE
    LUID targetAdapterID,   // LUID
    uint sourceID,   // DWORD
    wchar*** profileList,   // LPWSTR** out
    uint* profileCount   // DWORD* out
);
ccall((:ColorProfileGetDisplayList, "mscms.dll"), stdcall, Int32,
      (Int32, LUID, UInt32, Ptr{Ptr{UInt16}}, Ptr{UInt32}),
      scope, targetAdapterID, sourceID, profileList, profileCount)
# scope : WCS_PROFILE_MANAGEMENT_SCOPE -> Int32
# targetAdapterID : LUID -> LUID
# sourceID : DWORD -> UInt32
# profileList : LPWSTR** out -> Ptr{Ptr{UInt16}}
# profileCount : DWORD* out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t ColorProfileGetDisplayList(
    int32_t scope,
    LUID targetAdapterID,
    uint32_t sourceID,
    uint16_t*** profileList,
    uint32_t* profileCount);
]]
local mscms = ffi.load("mscms")
-- mscms.ColorProfileGetDisplayList(scope, targetAdapterID, sourceID, profileList, profileCount)
-- scope : WCS_PROFILE_MANAGEMENT_SCOPE
-- targetAdapterID : LUID
-- sourceID : DWORD
-- profileList : LPWSTR** out
-- profileCount : DWORD* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('mscms.dll');
const ColorProfileGetDisplayList = lib.func('__stdcall', 'ColorProfileGetDisplayList', 'int32_t', ['int32_t', 'LUID', 'uint32_t', 'void *', 'uint32_t *']);
// ColorProfileGetDisplayList(scope, targetAdapterID, sourceID, profileList, profileCount)
// scope : WCS_PROFILE_MANAGEMENT_SCOPE -> 'int32_t'
// targetAdapterID : LUID -> 'LUID'
// sourceID : DWORD -> 'uint32_t'
// profileList : LPWSTR** out -> 'void *'
// profileCount : DWORD* out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("mscms.dll", {
  ColorProfileGetDisplayList: { parameters: ["i32", "buffer", "u32", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.ColorProfileGetDisplayList(scope, targetAdapterID, sourceID, profileList, profileCount)
// scope : WCS_PROFILE_MANAGEMENT_SCOPE -> "i32"
// targetAdapterID : LUID -> "buffer"
// sourceID : DWORD -> "u32"
// profileList : LPWSTR** out -> "pointer"
// profileCount : DWORD* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t ColorProfileGetDisplayList(
    int32_t scope,
    LUID targetAdapterID,
    uint32_t sourceID,
    uint16_t*** profileList,
    uint32_t* profileCount);
C, "mscms.dll");
// $ffi->ColorProfileGetDisplayList(scope, targetAdapterID, sourceID, profileList, profileCount);
// scope : WCS_PROFILE_MANAGEMENT_SCOPE
// targetAdapterID : LUID
// sourceID : DWORD
// profileList : LPWSTR** out
// profileCount : DWORD* out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Mscms extends StdCallLibrary {
    Mscms INSTANCE = Native.load("mscms", Mscms.class);
    int ColorProfileGetDisplayList(
        int scope,   // WCS_PROFILE_MANAGEMENT_SCOPE
        LUID /* extends Structure (by value) */ targetAdapterID,   // LUID
        int sourceID,   // DWORD
        PointerByReference profileList,   // LPWSTR** out
        IntByReference profileCount   // DWORD* out
    );
}
@[Link("mscms")]
lib Libmscms
  fun ColorProfileGetDisplayList = ColorProfileGetDisplayList(
    scope : Int32,   # WCS_PROFILE_MANAGEMENT_SCOPE
    targetAdapterID : LUID,   # LUID
    sourceID : UInt32,   # DWORD
    profileList : UInt16***,   # LPWSTR** out
    profileCount : UInt32*   # DWORD* out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef ColorProfileGetDisplayListNative = Int32 Function(Int32, LUID, Uint32, Pointer<Pointer<Utf16>>, Pointer<Uint32>);
typedef ColorProfileGetDisplayListDart = int Function(int, int, int, Pointer<Pointer<Utf16>>, Pointer<Uint32>);
final ColorProfileGetDisplayList = DynamicLibrary.open('mscms.dll')
    .lookupFunction<ColorProfileGetDisplayListNative, ColorProfileGetDisplayListDart>('ColorProfileGetDisplayList');
// scope : WCS_PROFILE_MANAGEMENT_SCOPE -> Int32
// targetAdapterID : LUID -> LUID
// sourceID : DWORD -> Uint32
// profileList : LPWSTR** out -> Pointer<Pointer<Utf16>>
// profileCount : DWORD* out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function ColorProfileGetDisplayList(
  scope: Integer;   // WCS_PROFILE_MANAGEMENT_SCOPE
  targetAdapterID: LUID;   // LUID
  sourceID: DWORD;   // DWORD
  profileList: PPWideChar;   // LPWSTR** out
  profileCount: Pointer   // DWORD* out
): Integer; stdcall;
  external 'mscms.dll' name 'ColorProfileGetDisplayList';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "ColorProfileGetDisplayList"
  c_ColorProfileGetDisplayList :: Int32 -> LUID -> Word32 -> Ptr CWString -> Ptr Word32 -> IO Int32
-- scope : WCS_PROFILE_MANAGEMENT_SCOPE -> Int32
-- targetAdapterID : LUID -> LUID
-- sourceID : DWORD -> Word32
-- profileList : LPWSTR** out -> Ptr CWString
-- profileCount : DWORD* out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
-- ※値渡し構造体は GHC FFI で直接渡せません。Ptr で渡すラッパ(C側)経由にしてください。
open Ctypes
open Foreign

let colorprofilegetdisplaylist =
  foreign "ColorProfileGetDisplayList"
    (int32_t @-> LUID @-> uint32_t @-> (ptr (ptr uint16_t)) @-> (ptr uint32_t) @-> returning int32_t)
(* scope : WCS_PROFILE_MANAGEMENT_SCOPE -> int32_t *)
(* targetAdapterID : LUID -> LUID *)
(* sourceID : DWORD -> uint32_t *)
(* profileList : LPWSTR** out -> (ptr (ptr uint16_t)) *)
(* profileCount : DWORD* out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library mscms (t "mscms.dll"))
(cffi:use-foreign-library mscms)

(cffi:defcfun ("ColorProfileGetDisplayList" color-profile-get-display-list :convention :stdcall) :int32
  (scope :int32)   ; WCS_PROFILE_MANAGEMENT_SCOPE
  (target-adapter-id (:struct luid))   ; LUID
  (source-id :uint32)   ; DWORD
  (profile-list :pointer)   ; LPWSTR** out
  (profile-count :pointer))   ; DWORD* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $ColorProfileGetDisplayList = Win32::API::More->new('mscms',
    'int ColorProfileGetDisplayList(int scope, LPVOID targetAdapterID, DWORD sourceID, LPVOID profileList, LPVOID profileCount)');
# my $ret = $ColorProfileGetDisplayList->Call($scope, $targetAdapterID, $sourceID, $profileList, $profileCount);
# scope : WCS_PROFILE_MANAGEMENT_SCOPE -> int
# targetAdapterID : LUID -> LPVOID
# sourceID : DWORD -> DWORD
# profileList : LPWSTR** out -> LPVOID
# profileCount : DWORD* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型