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

ClusterRegCreateKeyEx

関数
理由付きでクラスターレジストリのサブキーを作成または開く。
DLLCLUSAPI.dll呼出規約winapi

シグネチャ

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

INT ClusterRegCreateKeyEx(
    HKEY hKey,
    LPCWSTR lpSubKey,
    DWORD dwOptions,
    DWORD samDesired,
    SECURITY_ATTRIBUTES* lpSecurityAttributes,   // optional
    HKEY* phkResult,
    DWORD* lpdwDisposition,   // optional
    LPCWSTR lpszReason   // optional
);

パラメーター

名前方向
hKeyHKEYin
lpSubKeyLPCWSTRin
dwOptionsDWORDin
samDesiredDWORDin
lpSecurityAttributesSECURITY_ATTRIBUTES*inoptional
phkResultHKEY*out
lpdwDispositionDWORD*outoptional
lpszReasonLPCWSTRinoptional

戻り値の型: INT

各言語での呼び出し定義

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

INT ClusterRegCreateKeyEx(
    HKEY hKey,
    LPCWSTR lpSubKey,
    DWORD dwOptions,
    DWORD samDesired,
    SECURITY_ATTRIBUTES* lpSecurityAttributes,   // optional
    HKEY* phkResult,
    DWORD* lpdwDisposition,   // optional
    LPCWSTR lpszReason   // optional
);
[DllImport("CLUSAPI.dll", ExactSpelling = true)]
static extern int ClusterRegCreateKeyEx(
    IntPtr hKey,   // HKEY
    [MarshalAs(UnmanagedType.LPWStr)] string lpSubKey,   // LPCWSTR
    uint dwOptions,   // DWORD
    uint samDesired,   // DWORD
    IntPtr lpSecurityAttributes,   // SECURITY_ATTRIBUTES* optional
    IntPtr phkResult,   // HKEY* out
    IntPtr lpdwDisposition,   // DWORD* optional, out
    [MarshalAs(UnmanagedType.LPWStr)] string lpszReason   // LPCWSTR optional
);
<DllImport("CLUSAPI.dll", ExactSpelling:=True)>
Public Shared Function ClusterRegCreateKeyEx(
    hKey As IntPtr,   ' HKEY
    <MarshalAs(UnmanagedType.LPWStr)> lpSubKey As String,   ' LPCWSTR
    dwOptions As UInteger,   ' DWORD
    samDesired As UInteger,   ' DWORD
    lpSecurityAttributes As IntPtr,   ' SECURITY_ATTRIBUTES* optional
    phkResult As IntPtr,   ' HKEY* out
    lpdwDisposition As IntPtr,   ' DWORD* optional, out
    <MarshalAs(UnmanagedType.LPWStr)> lpszReason As String   ' LPCWSTR optional
) As Integer
End Function
' hKey : HKEY
' lpSubKey : LPCWSTR
' dwOptions : DWORD
' samDesired : DWORD
' lpSecurityAttributes : SECURITY_ATTRIBUTES* optional
' phkResult : HKEY* out
' lpdwDisposition : DWORD* optional, out
' lpszReason : LPCWSTR optional
Declare PtrSafe Function ClusterRegCreateKeyEx Lib "clusapi" ( _
    ByVal hKey As LongPtr, _
    ByVal lpSubKey As LongPtr, _
    ByVal dwOptions As Long, _
    ByVal samDesired As Long, _
    ByVal lpSecurityAttributes As LongPtr, _
    ByVal phkResult As LongPtr, _
    ByVal lpdwDisposition As LongPtr, _
    ByVal lpszReason As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ClusterRegCreateKeyEx = ctypes.windll.clusapi.ClusterRegCreateKeyEx
ClusterRegCreateKeyEx.restype = ctypes.c_int
ClusterRegCreateKeyEx.argtypes = [
    wintypes.HANDLE,  # hKey : HKEY
    wintypes.LPCWSTR,  # lpSubKey : LPCWSTR
    wintypes.DWORD,  # dwOptions : DWORD
    wintypes.DWORD,  # samDesired : DWORD
    ctypes.c_void_p,  # lpSecurityAttributes : SECURITY_ATTRIBUTES* optional
    ctypes.c_void_p,  # phkResult : HKEY* out
    ctypes.POINTER(wintypes.DWORD),  # lpdwDisposition : DWORD* optional, out
    wintypes.LPCWSTR,  # lpszReason : LPCWSTR optional
]
require 'fiddle'
require 'fiddle/import'

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

var (
	clusapi = windows.NewLazySystemDLL("CLUSAPI.dll")
	procClusterRegCreateKeyEx = clusapi.NewProc("ClusterRegCreateKeyEx")
)

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