ホーム › UI.ColorSystem › GetStandardColorSpaceProfileW
GetStandardColorSpaceProfileW
関数標準色空間の既定プロファイルを取得する(Unicode版)。
シグネチャ
// mscms.dll (Unicode / -W)
#include <windows.h>
BOOL GetStandardColorSpaceProfileW(
LPCWSTR pMachineName, // optional
DWORD dwSCS,
LPWSTR pBuffer, // optional
DWORD* pcbSize
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pMachineName | LPCWSTR | inoptional | 対象マシン名を指すワイド文字列ポインタ。ローカルではNULLを指定する。 |
| dwSCS | DWORD | in | 取得対象の標準色空間を識別するID(sRGB等のSCS定数)。 |
| pBuffer | LPWSTR | outoptional | 対応するプロファイルのファイルパスを受け取るワイド文字バッファ。 |
| pcbSize | DWORD* | inout | 入出力としてバッファサイズを受け渡すポインタ。必要サイズが返る。 |
戻り値の型: BOOL
各言語での呼び出し定義
// mscms.dll (Unicode / -W)
#include <windows.h>
BOOL GetStandardColorSpaceProfileW(
LPCWSTR pMachineName, // optional
DWORD dwSCS,
LPWSTR pBuffer, // optional
DWORD* pcbSize
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("mscms.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern bool GetStandardColorSpaceProfileW(
[MarshalAs(UnmanagedType.LPWStr)] string pMachineName, // LPCWSTR optional
uint dwSCS, // DWORD
[MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pBuffer, // LPWSTR optional, out
ref uint pcbSize // DWORD* in/out
);<DllImport("mscms.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function GetStandardColorSpaceProfileW(
<MarshalAs(UnmanagedType.LPWStr)> pMachineName As String, ' LPCWSTR optional
dwSCS As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPWStr)> pBuffer As System.Text.StringBuilder, ' LPWSTR optional, out
ByRef pcbSize As UInteger ' DWORD* in/out
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' pMachineName : LPCWSTR optional
' dwSCS : DWORD
' pBuffer : LPWSTR optional, out
' pcbSize : DWORD* in/out
Declare PtrSafe Function GetStandardColorSpaceProfileW Lib "mscms" ( _
ByVal pMachineName As LongPtr, _
ByVal dwSCS As Long, _
ByVal pBuffer As LongPtr, _
ByRef pcbSize As Long) 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
GetStandardColorSpaceProfileW = ctypes.windll.mscms.GetStandardColorSpaceProfileW
GetStandardColorSpaceProfileW.restype = wintypes.BOOL
GetStandardColorSpaceProfileW.argtypes = [
wintypes.LPCWSTR, # pMachineName : LPCWSTR optional
wintypes.DWORD, # dwSCS : DWORD
wintypes.LPWSTR, # pBuffer : LPWSTR optional, out
ctypes.POINTER(wintypes.DWORD), # pcbSize : DWORD* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('mscms.dll')
GetStandardColorSpaceProfileW = Fiddle::Function.new(
lib['GetStandardColorSpaceProfileW'],
[
Fiddle::TYPE_VOIDP, # pMachineName : LPCWSTR optional
-Fiddle::TYPE_INT, # dwSCS : DWORD
Fiddle::TYPE_VOIDP, # pBuffer : LPWSTR optional, out
Fiddle::TYPE_VOIDP, # pcbSize : DWORD* in/out
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "mscms")]
extern "system" {
fn GetStandardColorSpaceProfileW(
pMachineName: *const u16, // LPCWSTR optional
dwSCS: u32, // DWORD
pBuffer: *mut u16, // LPWSTR optional, out
pcbSize: *mut u32 // DWORD* in/out
) -> 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 GetStandardColorSpaceProfileW([MarshalAs(UnmanagedType.LPWStr)] string pMachineName, uint dwSCS, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pBuffer, ref uint pcbSize);
"@
$api = Add-Type -MemberDefinition $sig -Name 'mscms_GetStandardColorSpaceProfileW' -Namespace Win32 -PassThru
# $api::GetStandardColorSpaceProfileW(pMachineName, dwSCS, pBuffer, pcbSize)#uselib "mscms.dll"
#func global GetStandardColorSpaceProfileW "GetStandardColorSpaceProfileW" wptr, wptr, wptr, wptr
; GetStandardColorSpaceProfileW pMachineName, dwSCS, varptr(pBuffer), varptr(pcbSize) ; 戻り値は stat
; pMachineName : LPCWSTR optional -> "wptr"
; dwSCS : DWORD -> "wptr"
; pBuffer : LPWSTR optional, out -> "wptr"
; pcbSize : DWORD* in/out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "mscms.dll" #cfunc global GetStandardColorSpaceProfileW "GetStandardColorSpaceProfileW" wstr, int, var, var ; res = GetStandardColorSpaceProfileW(pMachineName, dwSCS, pBuffer, pcbSize) ; pMachineName : LPCWSTR optional -> "wstr" ; dwSCS : DWORD -> "int" ; pBuffer : LPWSTR optional, out -> "var" ; pcbSize : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "mscms.dll" #cfunc global GetStandardColorSpaceProfileW "GetStandardColorSpaceProfileW" wstr, int, sptr, sptr ; res = GetStandardColorSpaceProfileW(pMachineName, dwSCS, varptr(pBuffer), varptr(pcbSize)) ; pMachineName : LPCWSTR optional -> "wstr" ; dwSCS : DWORD -> "int" ; pBuffer : LPWSTR optional, out -> "sptr" ; pcbSize : DWORD* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL GetStandardColorSpaceProfileW(LPCWSTR pMachineName, DWORD dwSCS, LPWSTR pBuffer, DWORD* pcbSize) #uselib "mscms.dll" #cfunc global GetStandardColorSpaceProfileW "GetStandardColorSpaceProfileW" wstr, int, var, var ; res = GetStandardColorSpaceProfileW(pMachineName, dwSCS, pBuffer, pcbSize) ; pMachineName : LPCWSTR optional -> "wstr" ; dwSCS : DWORD -> "int" ; pBuffer : LPWSTR optional, out -> "var" ; pcbSize : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL GetStandardColorSpaceProfileW(LPCWSTR pMachineName, DWORD dwSCS, LPWSTR pBuffer, DWORD* pcbSize) #uselib "mscms.dll" #cfunc global GetStandardColorSpaceProfileW "GetStandardColorSpaceProfileW" wstr, int, intptr, intptr ; res = GetStandardColorSpaceProfileW(pMachineName, dwSCS, varptr(pBuffer), varptr(pcbSize)) ; pMachineName : LPCWSTR optional -> "wstr" ; dwSCS : DWORD -> "int" ; pBuffer : LPWSTR optional, out -> "intptr" ; pcbSize : DWORD* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
mscms = windows.NewLazySystemDLL("mscms.dll")
procGetStandardColorSpaceProfileW = mscms.NewProc("GetStandardColorSpaceProfileW")
)
// pMachineName (LPCWSTR optional), dwSCS (DWORD), pBuffer (LPWSTR optional, out), pcbSize (DWORD* in/out)
r1, _, err := procGetStandardColorSpaceProfileW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pMachineName))),
uintptr(dwSCS),
uintptr(pBuffer),
uintptr(pcbSize),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction GetStandardColorSpaceProfileW(
pMachineName: PWideChar; // LPCWSTR optional
dwSCS: DWORD; // DWORD
pBuffer: PWideChar; // LPWSTR optional, out
pcbSize: Pointer // DWORD* in/out
): BOOL; stdcall;
external 'mscms.dll' name 'GetStandardColorSpaceProfileW';result := DllCall("mscms\GetStandardColorSpaceProfileW"
, "WStr", pMachineName ; LPCWSTR optional
, "UInt", dwSCS ; DWORD
, "Ptr", pBuffer ; LPWSTR optional, out
, "Ptr", pcbSize ; DWORD* in/out
, "Int") ; return: BOOL●GetStandardColorSpaceProfileW(pMachineName, dwSCS, pBuffer, pcbSize) = DLL("mscms.dll", "bool GetStandardColorSpaceProfileW(char*, dword, char*, void*)")
# 呼び出し: GetStandardColorSpaceProfileW(pMachineName, dwSCS, pBuffer, pcbSize)
# pMachineName : LPCWSTR optional -> "char*"
# dwSCS : DWORD -> "dword"
# pBuffer : LPWSTR optional, out -> "char*"
# pcbSize : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。const std = @import("std");
extern "mscms" fn GetStandardColorSpaceProfileW(
pMachineName: [*c]const u16, // LPCWSTR optional
dwSCS: u32, // DWORD
pBuffer: [*c]u16, // LPWSTR optional, out
pcbSize: [*c]u32 // DWORD* in/out
) callconv(std.os.windows.WINAPI) i32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc GetStandardColorSpaceProfileW(
pMachineName: WideCString, # LPCWSTR optional
dwSCS: uint32, # DWORD
pBuffer: ptr uint16, # LPWSTR optional, out
pcbSize: ptr uint32 # DWORD* in/out
): int32 {.importc: "GetStandardColorSpaceProfileW", stdcall, dynlib: "mscms.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "mscms");
extern(Windows)
int GetStandardColorSpaceProfileW(
const(wchar)* pMachineName, // LPCWSTR optional
uint dwSCS, // DWORD
wchar* pBuffer, // LPWSTR optional, out
uint* pcbSize // DWORD* in/out
);ccall((:GetStandardColorSpaceProfileW, "mscms.dll"), stdcall, Int32,
(Cwstring, UInt32, Ptr{UInt16}, Ptr{UInt32}),
pMachineName, dwSCS, pBuffer, pcbSize)
# pMachineName : LPCWSTR optional -> Cwstring
# dwSCS : DWORD -> UInt32
# pBuffer : LPWSTR optional, out -> Ptr{UInt16}
# pcbSize : DWORD* in/out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
int32_t GetStandardColorSpaceProfileW(
const uint16_t* pMachineName,
uint32_t dwSCS,
uint16_t* pBuffer,
uint32_t* pcbSize);
]]
local mscms = ffi.load("mscms")
-- mscms.GetStandardColorSpaceProfileW(pMachineName, dwSCS, pBuffer, pcbSize)
-- pMachineName : LPCWSTR optional
-- dwSCS : DWORD
-- pBuffer : LPWSTR optional, out
-- pcbSize : DWORD* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。const koffi = require('koffi');
const lib = koffi.load('mscms.dll');
const GetStandardColorSpaceProfileW = lib.func('__stdcall', 'GetStandardColorSpaceProfileW', 'int32_t', ['str16', 'uint32_t', 'uint16_t *', 'uint32_t *']);
// GetStandardColorSpaceProfileW(pMachineName, dwSCS, pBuffer, pcbSize)
// pMachineName : LPCWSTR optional -> 'str16'
// dwSCS : DWORD -> 'uint32_t'
// pBuffer : LPWSTR optional, out -> 'uint16_t *'
// pcbSize : DWORD* in/out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("mscms.dll", {
GetStandardColorSpaceProfileW: { parameters: ["buffer", "u32", "buffer", "pointer"], result: "i32" },
});
// lib.symbols.GetStandardColorSpaceProfileW(pMachineName, dwSCS, pBuffer, pcbSize)
// pMachineName : LPCWSTR optional -> "buffer"
// dwSCS : DWORD -> "u32"
// pBuffer : LPWSTR optional, out -> "buffer"
// pcbSize : DWORD* in/out -> "pointer"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t GetStandardColorSpaceProfileW(
const uint16_t* pMachineName,
uint32_t dwSCS,
uint16_t* pBuffer,
uint32_t* pcbSize);
C, "mscms.dll");
// $ffi->GetStandardColorSpaceProfileW(pMachineName, dwSCS, pBuffer, pcbSize);
// pMachineName : LPCWSTR optional
// dwSCS : DWORD
// pBuffer : LPWSTR optional, out
// pcbSize : DWORD* in/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, W32APIOptions.UNICODE_OPTIONS);
boolean GetStandardColorSpaceProfileW(
WString pMachineName, // LPCWSTR optional
int dwSCS, // DWORD
char[] pBuffer, // LPWSTR optional, out
IntByReference pcbSize // DWORD* in/out
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("mscms")]
lib Libmscms
fun GetStandardColorSpaceProfileW = GetStandardColorSpaceProfileW(
pMachineName : UInt16*, # LPCWSTR optional
dwSCS : UInt32, # DWORD
pBuffer : UInt16*, # LPWSTR optional, out
pcbSize : UInt32* # DWORD* in/out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef GetStandardColorSpaceProfileWNative = Int32 Function(Pointer<Utf16>, Uint32, Pointer<Utf16>, Pointer<Uint32>);
typedef GetStandardColorSpaceProfileWDart = int Function(Pointer<Utf16>, int, Pointer<Utf16>, Pointer<Uint32>);
final GetStandardColorSpaceProfileW = DynamicLibrary.open('mscms.dll')
.lookupFunction<GetStandardColorSpaceProfileWNative, GetStandardColorSpaceProfileWDart>('GetStandardColorSpaceProfileW');
// pMachineName : LPCWSTR optional -> Pointer<Utf16>
// dwSCS : DWORD -> Uint32
// pBuffer : LPWSTR optional, out -> Pointer<Utf16>
// pcbSize : DWORD* in/out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function GetStandardColorSpaceProfileW(
pMachineName: PWideChar; // LPCWSTR optional
dwSCS: DWORD; // DWORD
pBuffer: PWideChar; // LPWSTR optional, out
pcbSize: Pointer // DWORD* in/out
): BOOL; stdcall;
external 'mscms.dll' name 'GetStandardColorSpaceProfileW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "GetStandardColorSpaceProfileW"
c_GetStandardColorSpaceProfileW :: CWString -> Word32 -> CWString -> Ptr Word32 -> IO CInt
-- pMachineName : LPCWSTR optional -> CWString
-- dwSCS : DWORD -> Word32
-- pBuffer : LPWSTR optional, out -> CWString
-- pcbSize : DWORD* in/out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let getstandardcolorspaceprofilew =
foreign "GetStandardColorSpaceProfileW"
((ptr uint16_t) @-> uint32_t @-> (ptr uint16_t) @-> (ptr uint32_t) @-> returning int32_t)
(* pMachineName : LPCWSTR optional -> (ptr uint16_t) *)
(* dwSCS : DWORD -> uint32_t *)
(* pBuffer : LPWSTR optional, out -> (ptr uint16_t) *)
(* pcbSize : DWORD* in/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 ("GetStandardColorSpaceProfileW" get-standard-color-space-profile-w :convention :stdcall) :int32
(p-machine-name (:string :encoding :utf-16le)) ; LPCWSTR optional
(dw-scs :uint32) ; DWORD
(p-buffer :pointer) ; LPWSTR optional, out
(pcb-size :pointer)) ; DWORD* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $GetStandardColorSpaceProfileW = Win32::API::More->new('mscms',
'BOOL GetStandardColorSpaceProfileW(LPCWSTR pMachineName, DWORD dwSCS, LPWSTR pBuffer, LPVOID pcbSize)');
# my $ret = $GetStandardColorSpaceProfileW->Call($pMachineName, $dwSCS, $pBuffer, $pcbSize);
# pMachineName : LPCWSTR optional -> LPCWSTR
# dwSCS : DWORD -> DWORD
# pBuffer : LPWSTR optional, out -> LPWSTR
# pcbSize : DWORD* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
文字セット違い
- f GetStandardColorSpaceProfileA (ANSI版) — 標準色空間の既定プロファイルを取得する(ANSI版)。