Win32 API 日本語リファレンス
ホームNetworkManagement.WindowsConnectionManager › WcmSetProperty

WcmSetProperty

関数
接続マネージャーのインターフェイスまたはプロファイルのプロパティを設定する。
DLLwcmapi.dll呼出規約winapi対応OSwindows8.0

シグネチャ

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

DWORD WcmSetProperty(
    const GUID* pInterface,   // optional
    LPCWSTR strProfileName,   // optional
    WCM_PROPERTY Property,
    void* pReserved,   // optional
    DWORD dwDataSize,
    const BYTE* pbData   // optional
);

パラメーター

名前方向
pInterfaceGUID*inoptional
strProfileNameLPCWSTRinoptional
PropertyWCM_PROPERTYin
pReservedvoid*optional
dwDataSizeDWORDin
pbDataBYTE*inoptional

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD WcmSetProperty(
    const GUID* pInterface,   // optional
    LPCWSTR strProfileName,   // optional
    WCM_PROPERTY Property,
    void* pReserved,   // optional
    DWORD dwDataSize,
    const BYTE* pbData   // optional
);
[DllImport("wcmapi.dll", ExactSpelling = true)]
static extern uint WcmSetProperty(
    IntPtr pInterface,   // GUID* optional
    [MarshalAs(UnmanagedType.LPWStr)] string strProfileName,   // LPCWSTR optional
    int Property,   // WCM_PROPERTY
    IntPtr pReserved,   // void* optional
    uint dwDataSize,   // DWORD
    IntPtr pbData   // BYTE* optional
);
<DllImport("wcmapi.dll", ExactSpelling:=True)>
Public Shared Function WcmSetProperty(
    pInterface As IntPtr,   ' GUID* optional
    <MarshalAs(UnmanagedType.LPWStr)> strProfileName As String,   ' LPCWSTR optional
    [Property] As Integer,   ' WCM_PROPERTY
    pReserved As IntPtr,   ' void* optional
    dwDataSize As UInteger,   ' DWORD
    pbData As IntPtr   ' BYTE* optional
) As UInteger
End Function
' pInterface : GUID* optional
' strProfileName : LPCWSTR optional
' Property : WCM_PROPERTY
' pReserved : void* optional
' dwDataSize : DWORD
' pbData : BYTE* optional
Declare PtrSafe Function WcmSetProperty Lib "wcmapi" ( _
    ByVal pInterface As LongPtr, _
    ByVal strProfileName As LongPtr, _
    ByVal Property As Long, _
    ByVal pReserved As LongPtr, _
    ByVal dwDataSize As Long, _
    ByVal pbData As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WcmSetProperty = ctypes.windll.wcmapi.WcmSetProperty
WcmSetProperty.restype = wintypes.DWORD
WcmSetProperty.argtypes = [
    ctypes.c_void_p,  # pInterface : GUID* optional
    wintypes.LPCWSTR,  # strProfileName : LPCWSTR optional
    ctypes.c_int,  # Property : WCM_PROPERTY
    ctypes.POINTER(None),  # pReserved : void* optional
    wintypes.DWORD,  # dwDataSize : DWORD
    ctypes.POINTER(ctypes.c_ubyte),  # pbData : BYTE* optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('wcmapi.dll')
WcmSetProperty = Fiddle::Function.new(
  lib['WcmSetProperty'],
  [
    Fiddle::TYPE_VOIDP,  # pInterface : GUID* optional
    Fiddle::TYPE_VOIDP,  # strProfileName : LPCWSTR optional
    Fiddle::TYPE_INT,  # Property : WCM_PROPERTY
    Fiddle::TYPE_VOIDP,  # pReserved : void* optional
    -Fiddle::TYPE_INT,  # dwDataSize : DWORD
    Fiddle::TYPE_VOIDP,  # pbData : BYTE* optional
  ],
  -Fiddle::TYPE_INT)
#[link(name = "wcmapi")]
extern "system" {
    fn WcmSetProperty(
        pInterface: *const GUID,  // GUID* optional
        strProfileName: *const u16,  // LPCWSTR optional
        Property: i32,  // WCM_PROPERTY
        pReserved: *mut (),  // void* optional
        dwDataSize: u32,  // DWORD
        pbData: *const u8  // BYTE* optional
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("wcmapi.dll")]
public static extern uint WcmSetProperty(IntPtr pInterface, [MarshalAs(UnmanagedType.LPWStr)] string strProfileName, int Property, IntPtr pReserved, uint dwDataSize, IntPtr pbData);
"@
$api = Add-Type -MemberDefinition $sig -Name 'wcmapi_WcmSetProperty' -Namespace Win32 -PassThru
# $api::WcmSetProperty(pInterface, strProfileName, Property, pReserved, dwDataSize, pbData)
#uselib "wcmapi.dll"
#func global WcmSetProperty "WcmSetProperty" sptr, sptr, sptr, sptr, sptr, sptr
; WcmSetProperty varptr(pInterface), strProfileName, Property, pReserved, dwDataSize, varptr(pbData)   ; 戻り値は stat
; pInterface : GUID* optional -> "sptr"
; strProfileName : LPCWSTR optional -> "sptr"
; Property : WCM_PROPERTY -> "sptr"
; pReserved : void* optional -> "sptr"
; dwDataSize : DWORD -> "sptr"
; pbData : BYTE* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "wcmapi.dll"
#cfunc global WcmSetProperty "WcmSetProperty" var, wstr, int, sptr, int, var
; res = WcmSetProperty(pInterface, strProfileName, Property, pReserved, dwDataSize, pbData)
; pInterface : GUID* optional -> "var"
; strProfileName : LPCWSTR optional -> "wstr"
; Property : WCM_PROPERTY -> "int"
; pReserved : void* optional -> "sptr"
; dwDataSize : DWORD -> "int"
; pbData : BYTE* optional -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD WcmSetProperty(GUID* pInterface, LPCWSTR strProfileName, WCM_PROPERTY Property, void* pReserved, DWORD dwDataSize, BYTE* pbData)
#uselib "wcmapi.dll"
#cfunc global WcmSetProperty "WcmSetProperty" var, wstr, int, intptr, int, var
; res = WcmSetProperty(pInterface, strProfileName, Property, pReserved, dwDataSize, pbData)
; pInterface : GUID* optional -> "var"
; strProfileName : LPCWSTR optional -> "wstr"
; Property : WCM_PROPERTY -> "int"
; pReserved : void* optional -> "intptr"
; dwDataSize : DWORD -> "int"
; pbData : BYTE* optional -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wcmapi = windows.NewLazySystemDLL("wcmapi.dll")
	procWcmSetProperty = wcmapi.NewProc("WcmSetProperty")
)

// pInterface (GUID* optional), strProfileName (LPCWSTR optional), Property (WCM_PROPERTY), pReserved (void* optional), dwDataSize (DWORD), pbData (BYTE* optional)
r1, _, err := procWcmSetProperty.Call(
	uintptr(pInterface),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(strProfileName))),
	uintptr(Property),
	uintptr(pReserved),
	uintptr(dwDataSize),
	uintptr(pbData),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function WcmSetProperty(
  pInterface: PGUID;   // GUID* optional
  strProfileName: PWideChar;   // LPCWSTR optional
  Property: Integer;   // WCM_PROPERTY
  pReserved: Pointer;   // void* optional
  dwDataSize: DWORD;   // DWORD
  pbData: Pointer   // BYTE* optional
): DWORD; stdcall;
  external 'wcmapi.dll' name 'WcmSetProperty';
result := DllCall("wcmapi\WcmSetProperty"
    , "Ptr", pInterface   ; GUID* optional
    , "WStr", strProfileName   ; LPCWSTR optional
    , "Int", Property   ; WCM_PROPERTY
    , "Ptr", pReserved   ; void* optional
    , "UInt", dwDataSize   ; DWORD
    , "Ptr", pbData   ; BYTE* optional
    , "UInt")   ; return: DWORD
●WcmSetProperty(pInterface, strProfileName, Property, pReserved, dwDataSize, pbData) = DLL("wcmapi.dll", "dword WcmSetProperty(void*, char*, int, void*, dword, void*)")
# 呼び出し: WcmSetProperty(pInterface, strProfileName, Property, pReserved, dwDataSize, pbData)
# pInterface : GUID* optional -> "void*"
# strProfileName : LPCWSTR optional -> "char*"
# Property : WCM_PROPERTY -> "int"
# pReserved : void* optional -> "void*"
# dwDataSize : DWORD -> "dword"
# pbData : BYTE* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。