Win32 API 日本語リファレンス
ホームNetworking.Clustering › ClusterRegSetValueEx

ClusterRegSetValueEx

関数
理由付きでクラスターレジストリキーに値を設定する。
DLLCLUSAPI.dll呼出規約winapi

シグネチャ

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

DWORD ClusterRegSetValueEx(
    HKEY hKey,
    LPCWSTR lpszValueName,
    DWORD dwType,
    const BYTE* lpData,
    DWORD cbData,
    LPCWSTR lpszReason   // optional
);

パラメーター

名前方向
hKeyHKEYin
lpszValueNameLPCWSTRin
dwTypeDWORDin
lpDataBYTE*in
cbDataDWORDin
lpszReasonLPCWSTRinoptional

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD ClusterRegSetValueEx(
    HKEY hKey,
    LPCWSTR lpszValueName,
    DWORD dwType,
    const BYTE* lpData,
    DWORD cbData,
    LPCWSTR lpszReason   // optional
);
[DllImport("CLUSAPI.dll", ExactSpelling = true)]
static extern uint ClusterRegSetValueEx(
    IntPtr hKey,   // HKEY
    [MarshalAs(UnmanagedType.LPWStr)] string lpszValueName,   // LPCWSTR
    uint dwType,   // DWORD
    IntPtr lpData,   // BYTE*
    uint cbData,   // DWORD
    [MarshalAs(UnmanagedType.LPWStr)] string lpszReason   // LPCWSTR optional
);
<DllImport("CLUSAPI.dll", ExactSpelling:=True)>
Public Shared Function ClusterRegSetValueEx(
    hKey As IntPtr,   ' HKEY
    <MarshalAs(UnmanagedType.LPWStr)> lpszValueName As String,   ' LPCWSTR
    dwType As UInteger,   ' DWORD
    lpData As IntPtr,   ' BYTE*
    cbData As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPWStr)> lpszReason As String   ' LPCWSTR optional
) As UInteger
End Function
' hKey : HKEY
' lpszValueName : LPCWSTR
' dwType : DWORD
' lpData : BYTE*
' cbData : DWORD
' lpszReason : LPCWSTR optional
Declare PtrSafe Function ClusterRegSetValueEx Lib "clusapi" ( _
    ByVal hKey As LongPtr, _
    ByVal lpszValueName As LongPtr, _
    ByVal dwType As Long, _
    ByVal lpData As LongPtr, _
    ByVal cbData As Long, _
    ByVal lpszReason As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ClusterRegSetValueEx = ctypes.windll.clusapi.ClusterRegSetValueEx
ClusterRegSetValueEx.restype = wintypes.DWORD
ClusterRegSetValueEx.argtypes = [
    wintypes.HANDLE,  # hKey : HKEY
    wintypes.LPCWSTR,  # lpszValueName : LPCWSTR
    wintypes.DWORD,  # dwType : DWORD
    ctypes.POINTER(ctypes.c_ubyte),  # lpData : BYTE*
    wintypes.DWORD,  # cbData : DWORD
    wintypes.LPCWSTR,  # lpszReason : LPCWSTR optional
]
require 'fiddle'
require 'fiddle/import'

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

var (
	clusapi = windows.NewLazySystemDLL("CLUSAPI.dll")
	procClusterRegSetValueEx = clusapi.NewProc("ClusterRegSetValueEx")
)

// hKey (HKEY), lpszValueName (LPCWSTR), dwType (DWORD), lpData (BYTE*), cbData (DWORD), lpszReason (LPCWSTR optional)
r1, _, err := procClusterRegSetValueEx.Call(
	uintptr(hKey),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszValueName))),
	uintptr(dwType),
	uintptr(lpData),
	uintptr(cbData),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszReason))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function ClusterRegSetValueEx(
  hKey: THandle;   // HKEY
  lpszValueName: PWideChar;   // LPCWSTR
  dwType: DWORD;   // DWORD
  lpData: Pointer;   // BYTE*
  cbData: DWORD;   // DWORD
  lpszReason: PWideChar   // LPCWSTR optional
): DWORD; stdcall;
  external 'CLUSAPI.dll' name 'ClusterRegSetValueEx';
result := DllCall("CLUSAPI\ClusterRegSetValueEx"
    , "Ptr", hKey   ; HKEY
    , "WStr", lpszValueName   ; LPCWSTR
    , "UInt", dwType   ; DWORD
    , "Ptr", lpData   ; BYTE*
    , "UInt", cbData   ; DWORD
    , "WStr", lpszReason   ; LPCWSTR optional
    , "UInt")   ; return: DWORD
●ClusterRegSetValueEx(hKey, lpszValueName, dwType, lpData, cbData, lpszReason) = DLL("CLUSAPI.dll", "dword ClusterRegSetValueEx(void*, char*, dword, void*, dword, char*)")
# 呼び出し: ClusterRegSetValueEx(hKey, lpszValueName, dwType, lpData, cbData, lpszReason)
# hKey : HKEY -> "void*"
# lpszValueName : LPCWSTR -> "char*"
# dwType : DWORD -> "dword"
# lpData : BYTE* -> "void*"
# cbData : DWORD -> "dword"
# lpszReason : LPCWSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。