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

WcsSetUsePerUserProfiles

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

シグネチャ

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

BOOL WcsSetUsePerUserProfiles(
    LPCWSTR pDeviceName,
    DWORD dwDeviceClass,
    BOOL usePerUserProfiles
);

パラメーター

名前方向
pDeviceNameLPCWSTRin
dwDeviceClassDWORDin
usePerUserProfilesBOOLin

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL WcsSetUsePerUserProfiles(
    LPCWSTR pDeviceName,
    DWORD dwDeviceClass,
    BOOL usePerUserProfiles
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("mscms.dll", ExactSpelling = true)]
static extern bool WcsSetUsePerUserProfiles(
    [MarshalAs(UnmanagedType.LPWStr)] string pDeviceName,   // LPCWSTR
    uint dwDeviceClass,   // DWORD
    bool usePerUserProfiles   // BOOL
);
<DllImport("mscms.dll", ExactSpelling:=True)>
Public Shared Function WcsSetUsePerUserProfiles(
    <MarshalAs(UnmanagedType.LPWStr)> pDeviceName As String,   ' LPCWSTR
    dwDeviceClass As UInteger,   ' DWORD
    usePerUserProfiles As Boolean   ' BOOL
) As Boolean
End Function
' pDeviceName : LPCWSTR
' dwDeviceClass : DWORD
' usePerUserProfiles : BOOL
Declare PtrSafe Function WcsSetUsePerUserProfiles Lib "mscms" ( _
    ByVal pDeviceName As LongPtr, _
    ByVal dwDeviceClass As Long, _
    ByVal usePerUserProfiles As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WcsSetUsePerUserProfiles = ctypes.windll.mscms.WcsSetUsePerUserProfiles
WcsSetUsePerUserProfiles.restype = wintypes.BOOL
WcsSetUsePerUserProfiles.argtypes = [
    wintypes.LPCWSTR,  # pDeviceName : LPCWSTR
    wintypes.DWORD,  # dwDeviceClass : DWORD
    wintypes.BOOL,  # usePerUserProfiles : BOOL
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('mscms.dll')
WcsSetUsePerUserProfiles = Fiddle::Function.new(
  lib['WcsSetUsePerUserProfiles'],
  [
    Fiddle::TYPE_VOIDP,  # pDeviceName : LPCWSTR
    -Fiddle::TYPE_INT,  # dwDeviceClass : DWORD
    Fiddle::TYPE_INT,  # usePerUserProfiles : BOOL
  ],
  Fiddle::TYPE_INT)
#[link(name = "mscms")]
extern "system" {
    fn WcsSetUsePerUserProfiles(
        pDeviceName: *const u16,  // LPCWSTR
        dwDeviceClass: u32,  // DWORD
        usePerUserProfiles: i32  // BOOL
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("mscms.dll")]
public static extern bool WcsSetUsePerUserProfiles([MarshalAs(UnmanagedType.LPWStr)] string pDeviceName, uint dwDeviceClass, bool usePerUserProfiles);
"@
$api = Add-Type -MemberDefinition $sig -Name 'mscms_WcsSetUsePerUserProfiles' -Namespace Win32 -PassThru
# $api::WcsSetUsePerUserProfiles(pDeviceName, dwDeviceClass, usePerUserProfiles)
#uselib "mscms.dll"
#func global WcsSetUsePerUserProfiles "WcsSetUsePerUserProfiles" sptr, sptr, sptr
; WcsSetUsePerUserProfiles pDeviceName, dwDeviceClass, usePerUserProfiles   ; 戻り値は stat
; pDeviceName : LPCWSTR -> "sptr"
; dwDeviceClass : DWORD -> "sptr"
; usePerUserProfiles : BOOL -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "mscms.dll"
#cfunc global WcsSetUsePerUserProfiles "WcsSetUsePerUserProfiles" wstr, int, int
; res = WcsSetUsePerUserProfiles(pDeviceName, dwDeviceClass, usePerUserProfiles)
; pDeviceName : LPCWSTR -> "wstr"
; dwDeviceClass : DWORD -> "int"
; usePerUserProfiles : BOOL -> "int"
; BOOL WcsSetUsePerUserProfiles(LPCWSTR pDeviceName, DWORD dwDeviceClass, BOOL usePerUserProfiles)
#uselib "mscms.dll"
#cfunc global WcsSetUsePerUserProfiles "WcsSetUsePerUserProfiles" wstr, int, int
; res = WcsSetUsePerUserProfiles(pDeviceName, dwDeviceClass, usePerUserProfiles)
; pDeviceName : LPCWSTR -> "wstr"
; dwDeviceClass : DWORD -> "int"
; usePerUserProfiles : BOOL -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	mscms = windows.NewLazySystemDLL("mscms.dll")
	procWcsSetUsePerUserProfiles = mscms.NewProc("WcsSetUsePerUserProfiles")
)

// pDeviceName (LPCWSTR), dwDeviceClass (DWORD), usePerUserProfiles (BOOL)
r1, _, err := procWcsSetUsePerUserProfiles.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pDeviceName))),
	uintptr(dwDeviceClass),
	uintptr(usePerUserProfiles),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function WcsSetUsePerUserProfiles(
  pDeviceName: PWideChar;   // LPCWSTR
  dwDeviceClass: DWORD;   // DWORD
  usePerUserProfiles: BOOL   // BOOL
): BOOL; stdcall;
  external 'mscms.dll' name 'WcsSetUsePerUserProfiles';
result := DllCall("mscms\WcsSetUsePerUserProfiles"
    , "WStr", pDeviceName   ; LPCWSTR
    , "UInt", dwDeviceClass   ; DWORD
    , "Int", usePerUserProfiles   ; BOOL
    , "Int")   ; return: BOOL
●WcsSetUsePerUserProfiles(pDeviceName, dwDeviceClass, usePerUserProfiles) = DLL("mscms.dll", "bool WcsSetUsePerUserProfiles(char*, dword, bool)")
# 呼び出し: WcsSetUsePerUserProfiles(pDeviceName, dwDeviceClass, usePerUserProfiles)
# pDeviceName : LPCWSTR -> "char*"
# dwDeviceClass : DWORD -> "dword"
# usePerUserProfiles : BOOL -> "bool"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。