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

WcsGetUsePerUserProfiles

関数
デバイスがユーザー別プロファイルを使うか取得する。
DLLmscms.dll呼出規約winapi

シグネチャ

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

BOOL WcsGetUsePerUserProfiles(
    LPCWSTR pDeviceName,
    DWORD dwDeviceClass,
    BOOL* pUsePerUserProfiles
);

パラメーター

名前方向
pDeviceNameLPCWSTRin
dwDeviceClassDWORDin
pUsePerUserProfilesBOOL*out

戻り値の型: 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 int 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 Integer   ' BOOL* out
) As 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 int 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, 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, int
; res = WcsGetUsePerUserProfiles(pDeviceName, dwDeviceClass, pUsePerUserProfiles)
; pDeviceName : LPCWSTR -> "wstr"
; dwDeviceClass : DWORD -> "int"
; pUsePerUserProfiles : BOOL* out -> "int"
; BOOL WcsGetUsePerUserProfiles(LPCWSTR pDeviceName, DWORD dwDeviceClass, BOOL* pUsePerUserProfiles)
#uselib "mscms.dll"
#cfunc global WcsGetUsePerUserProfiles "WcsGetUsePerUserProfiles" wstr, int, int
; res = WcsGetUsePerUserProfiles(pDeviceName, dwDeviceClass, pUsePerUserProfiles)
; pDeviceName : LPCWSTR -> "wstr"
; dwDeviceClass : DWORD -> "int"
; pUsePerUserProfiles : BOOL* out -> "int"
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   // BOOL
function 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)。