ホーム › UI.ColorSystem › WcsGetUsePerUserProfiles
WcsGetUsePerUserProfiles
関数デバイスがユーザー別プロファイルを使うか取得する。
シグネチャ
// mscms.dll
#include <windows.h>
BOOL WcsGetUsePerUserProfiles(
LPCWSTR pDeviceName,
DWORD dwDeviceClass,
BOOL* pUsePerUserProfiles
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pDeviceName | LPCWSTR | in | 設定を問い合わせる対象デバイス名を指すワイド文字列ポインタ。 |
| dwDeviceClass | DWORD | in | 対象デバイスのクラス(モニタ・プリンタ等)を示す値。 |
| pUsePerUserProfiles | BOOL* | out | ユーザー単位プロファイルを使用中ならTRUEが返るBOOL値へのポインタ。 |
戻り値の型: BOOL
各言語での呼び出し定義
// mscms.dll
#include <windows.h>
BOOL WcsGetUsePerUserProfiles(
LPCWSTR pDeviceName,
DWORD dwDeviceClass,
BOOL* pUsePerUserProfiles
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("mscms.dll", ExactSpelling = true)]
static extern bool WcsGetUsePerUserProfiles(
[MarshalAs(UnmanagedType.LPWStr)] string pDeviceName, // LPCWSTR
uint dwDeviceClass, // DWORD
out bool pUsePerUserProfiles // BOOL* out
);<DllImport("mscms.dll", ExactSpelling:=True)>
Public Shared Function WcsGetUsePerUserProfiles(
<MarshalAs(UnmanagedType.LPWStr)> pDeviceName As String, ' LPCWSTR
dwDeviceClass As UInteger, ' DWORD
<Out> ByRef pUsePerUserProfiles As Boolean ' BOOL* out
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' pDeviceName : LPCWSTR
' dwDeviceClass : DWORD
' pUsePerUserProfiles : BOOL* out
Declare PtrSafe Function WcsGetUsePerUserProfiles Lib "mscms" ( _
ByVal pDeviceName As LongPtr, _
ByVal dwDeviceClass As Long, _
ByRef pUsePerUserProfiles As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
WcsGetUsePerUserProfiles = ctypes.windll.mscms.WcsGetUsePerUserProfiles
WcsGetUsePerUserProfiles.restype = wintypes.BOOL
WcsGetUsePerUserProfiles.argtypes = [
wintypes.LPCWSTR, # pDeviceName : LPCWSTR
wintypes.DWORD, # dwDeviceClass : DWORD
ctypes.c_void_p, # pUsePerUserProfiles : BOOL* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('mscms.dll')
WcsGetUsePerUserProfiles = Fiddle::Function.new(
lib['WcsGetUsePerUserProfiles'],
[
Fiddle::TYPE_VOIDP, # pDeviceName : LPCWSTR
-Fiddle::TYPE_INT, # dwDeviceClass : DWORD
Fiddle::TYPE_VOIDP, # pUsePerUserProfiles : BOOL* out
],
Fiddle::TYPE_INT)#[link(name = "mscms")]
extern "system" {
fn WcsGetUsePerUserProfiles(
pDeviceName: *const u16, // LPCWSTR
dwDeviceClass: u32, // DWORD
pUsePerUserProfiles: *mut i32 // BOOL* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("mscms.dll")]
public static extern bool WcsGetUsePerUserProfiles([MarshalAs(UnmanagedType.LPWStr)] string pDeviceName, uint dwDeviceClass, out bool pUsePerUserProfiles);
"@
$api = Add-Type -MemberDefinition $sig -Name 'mscms_WcsGetUsePerUserProfiles' -Namespace Win32 -PassThru
# $api::WcsGetUsePerUserProfiles(pDeviceName, dwDeviceClass, pUsePerUserProfiles)#uselib "mscms.dll"
#func global WcsGetUsePerUserProfiles "WcsGetUsePerUserProfiles" sptr, sptr, sptr
; WcsGetUsePerUserProfiles pDeviceName, dwDeviceClass, varptr(pUsePerUserProfiles) ; 戻り値は stat
; pDeviceName : LPCWSTR -> "sptr"
; dwDeviceClass : DWORD -> "sptr"
; pUsePerUserProfiles : BOOL* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "mscms.dll" #cfunc global WcsGetUsePerUserProfiles "WcsGetUsePerUserProfiles" wstr, int, var ; res = WcsGetUsePerUserProfiles(pDeviceName, dwDeviceClass, pUsePerUserProfiles) ; pDeviceName : LPCWSTR -> "wstr" ; dwDeviceClass : DWORD -> "int" ; pUsePerUserProfiles : BOOL* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "mscms.dll" #cfunc global WcsGetUsePerUserProfiles "WcsGetUsePerUserProfiles" wstr, int, sptr ; res = WcsGetUsePerUserProfiles(pDeviceName, dwDeviceClass, varptr(pUsePerUserProfiles)) ; pDeviceName : LPCWSTR -> "wstr" ; dwDeviceClass : DWORD -> "int" ; pUsePerUserProfiles : BOOL* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL WcsGetUsePerUserProfiles(LPCWSTR pDeviceName, DWORD dwDeviceClass, BOOL* pUsePerUserProfiles) #uselib "mscms.dll" #cfunc global WcsGetUsePerUserProfiles "WcsGetUsePerUserProfiles" wstr, int, var ; res = WcsGetUsePerUserProfiles(pDeviceName, dwDeviceClass, pUsePerUserProfiles) ; pDeviceName : LPCWSTR -> "wstr" ; dwDeviceClass : DWORD -> "int" ; pUsePerUserProfiles : BOOL* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL WcsGetUsePerUserProfiles(LPCWSTR pDeviceName, DWORD dwDeviceClass, BOOL* pUsePerUserProfiles) #uselib "mscms.dll" #cfunc global WcsGetUsePerUserProfiles "WcsGetUsePerUserProfiles" wstr, int, intptr ; res = WcsGetUsePerUserProfiles(pDeviceName, dwDeviceClass, varptr(pUsePerUserProfiles)) ; pDeviceName : LPCWSTR -> "wstr" ; dwDeviceClass : DWORD -> "int" ; pUsePerUserProfiles : BOOL* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
mscms = windows.NewLazySystemDLL("mscms.dll")
procWcsGetUsePerUserProfiles = mscms.NewProc("WcsGetUsePerUserProfiles")
)
// pDeviceName (LPCWSTR), dwDeviceClass (DWORD), pUsePerUserProfiles (BOOL* out)
r1, _, err := procWcsGetUsePerUserProfiles.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pDeviceName))),
uintptr(dwDeviceClass),
uintptr(pUsePerUserProfiles),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction WcsGetUsePerUserProfiles(
pDeviceName: PWideChar; // LPCWSTR
dwDeviceClass: DWORD; // DWORD
pUsePerUserProfiles: Pointer // BOOL* out
): BOOL; stdcall;
external 'mscms.dll' name 'WcsGetUsePerUserProfiles';result := DllCall("mscms\WcsGetUsePerUserProfiles"
, "WStr", pDeviceName ; LPCWSTR
, "UInt", dwDeviceClass ; DWORD
, "Ptr", pUsePerUserProfiles ; BOOL* out
, "Int") ; return: BOOL●WcsGetUsePerUserProfiles(pDeviceName, dwDeviceClass, pUsePerUserProfiles) = DLL("mscms.dll", "bool WcsGetUsePerUserProfiles(char*, dword, void*)")
# 呼び出し: WcsGetUsePerUserProfiles(pDeviceName, dwDeviceClass, pUsePerUserProfiles)
# pDeviceName : LPCWSTR -> "char*"
# dwDeviceClass : DWORD -> "dword"
# pUsePerUserProfiles : BOOL* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "mscms" fn WcsGetUsePerUserProfiles(
pDeviceName: [*c]const u16, // LPCWSTR
dwDeviceClass: u32, // DWORD
pUsePerUserProfiles: [*c]i32 // BOOL* out
) callconv(std.os.windows.WINAPI) i32;proc WcsGetUsePerUserProfiles(
pDeviceName: WideCString, # LPCWSTR
dwDeviceClass: uint32, # DWORD
pUsePerUserProfiles: ptr int32 # BOOL* out
): int32 {.importc: "WcsGetUsePerUserProfiles", stdcall, dynlib: "mscms.dll".}pragma(lib, "mscms");
extern(Windows)
int WcsGetUsePerUserProfiles(
const(wchar)* pDeviceName, // LPCWSTR
uint dwDeviceClass, // DWORD
int* pUsePerUserProfiles // BOOL* out
);ccall((:WcsGetUsePerUserProfiles, "mscms.dll"), stdcall, Int32,
(Cwstring, UInt32, Ptr{Int32}),
pDeviceName, dwDeviceClass, pUsePerUserProfiles)
# pDeviceName : LPCWSTR -> Cwstring
# dwDeviceClass : DWORD -> UInt32
# pUsePerUserProfiles : BOOL* out -> Ptr{Int32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t WcsGetUsePerUserProfiles(
const uint16_t* pDeviceName,
uint32_t dwDeviceClass,
int32_t* pUsePerUserProfiles);
]]
local mscms = ffi.load("mscms")
-- mscms.WcsGetUsePerUserProfiles(pDeviceName, dwDeviceClass, pUsePerUserProfiles)
-- pDeviceName : LPCWSTR
-- dwDeviceClass : DWORD
-- pUsePerUserProfiles : BOOL* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('mscms.dll');
const WcsGetUsePerUserProfiles = lib.func('__stdcall', 'WcsGetUsePerUserProfiles', 'int32_t', ['str16', 'uint32_t', 'int32_t *']);
// WcsGetUsePerUserProfiles(pDeviceName, dwDeviceClass, pUsePerUserProfiles)
// pDeviceName : LPCWSTR -> 'str16'
// dwDeviceClass : DWORD -> 'uint32_t'
// pUsePerUserProfiles : BOOL* out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("mscms.dll", {
WcsGetUsePerUserProfiles: { parameters: ["buffer", "u32", "pointer"], result: "i32" },
});
// lib.symbols.WcsGetUsePerUserProfiles(pDeviceName, dwDeviceClass, pUsePerUserProfiles)
// pDeviceName : LPCWSTR -> "buffer"
// dwDeviceClass : DWORD -> "u32"
// pUsePerUserProfiles : BOOL* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t WcsGetUsePerUserProfiles(
const uint16_t* pDeviceName,
uint32_t dwDeviceClass,
int32_t* pUsePerUserProfiles);
C, "mscms.dll");
// $ffi->WcsGetUsePerUserProfiles(pDeviceName, dwDeviceClass, pUsePerUserProfiles);
// pDeviceName : LPCWSTR
// dwDeviceClass : DWORD
// pUsePerUserProfiles : BOOL* 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);
boolean WcsGetUsePerUserProfiles(
WString pDeviceName, // LPCWSTR
int dwDeviceClass, // DWORD
IntByReference pUsePerUserProfiles // BOOL* out
);
}@[Link("mscms")]
lib Libmscms
fun WcsGetUsePerUserProfiles = WcsGetUsePerUserProfiles(
pDeviceName : UInt16*, # LPCWSTR
dwDeviceClass : UInt32, # DWORD
pUsePerUserProfiles : Int32* # BOOL* out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef WcsGetUsePerUserProfilesNative = Int32 Function(Pointer<Utf16>, Uint32, Pointer<Int32>);
typedef WcsGetUsePerUserProfilesDart = int Function(Pointer<Utf16>, int, Pointer<Int32>);
final WcsGetUsePerUserProfiles = DynamicLibrary.open('mscms.dll')
.lookupFunction<WcsGetUsePerUserProfilesNative, WcsGetUsePerUserProfilesDart>('WcsGetUsePerUserProfiles');
// pDeviceName : LPCWSTR -> Pointer<Utf16>
// dwDeviceClass : DWORD -> Uint32
// pUsePerUserProfiles : BOOL* out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function WcsGetUsePerUserProfiles(
pDeviceName: PWideChar; // LPCWSTR
dwDeviceClass: DWORD; // DWORD
pUsePerUserProfiles: Pointer // BOOL* out
): BOOL; stdcall;
external 'mscms.dll' name 'WcsGetUsePerUserProfiles';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "WcsGetUsePerUserProfiles"
c_WcsGetUsePerUserProfiles :: CWString -> Word32 -> Ptr CInt -> IO CInt
-- pDeviceName : LPCWSTR -> CWString
-- dwDeviceClass : DWORD -> Word32
-- pUsePerUserProfiles : BOOL* out -> Ptr CInt
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let wcsgetuseperuserprofiles =
foreign "WcsGetUsePerUserProfiles"
((ptr uint16_t) @-> uint32_t @-> (ptr int32_t) @-> returning int32_t)
(* pDeviceName : LPCWSTR -> (ptr uint16_t) *)
(* dwDeviceClass : DWORD -> uint32_t *)
(* pUsePerUserProfiles : BOOL* out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library mscms (t "mscms.dll"))
(cffi:use-foreign-library mscms)
(cffi:defcfun ("WcsGetUsePerUserProfiles" wcs-get-use-per-user-profiles :convention :stdcall) :int32
(p-device-name (:string :encoding :utf-16le)) ; LPCWSTR
(dw-device-class :uint32) ; DWORD
(p-use-per-user-profiles :pointer)) ; BOOL* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $WcsGetUsePerUserProfiles = Win32::API::More->new('mscms',
'BOOL WcsGetUsePerUserProfiles(LPCWSTR pDeviceName, DWORD dwDeviceClass, LPVOID pUsePerUserProfiles)');
# my $ret = $WcsGetUsePerUserProfiles->Call($pDeviceName, $dwDeviceClass, $pUsePerUserProfiles);
# pDeviceName : LPCWSTR -> LPCWSTR
# dwDeviceClass : DWORD -> DWORD
# pUsePerUserProfiles : BOOL* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。