ホーム › Networking.Clustering › ClusterRegCreateKey
ClusterRegCreateKey
関数クラスターレジストリ内にサブキーを作成または開く。
シグネチャ
// CLUSAPI.dll
#include <windows.h>
INT ClusterRegCreateKey(
HKEY hKey,
LPCWSTR lpszSubKey,
DWORD dwOptions,
DWORD samDesired,
SECURITY_ATTRIBUTES* lpSecurityAttributes, // optional
HKEY* phkResult,
DWORD* lpdwDisposition // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hKey | HKEY | in |
| lpszSubKey | LPCWSTR | in |
| dwOptions | DWORD | in |
| samDesired | DWORD | in |
| lpSecurityAttributes | SECURITY_ATTRIBUTES* | inoptional |
| phkResult | HKEY* | out |
| lpdwDisposition | DWORD* | outoptional |
戻り値の型: INT
各言語での呼び出し定義
// CLUSAPI.dll
#include <windows.h>
INT ClusterRegCreateKey(
HKEY hKey,
LPCWSTR lpszSubKey,
DWORD dwOptions,
DWORD samDesired,
SECURITY_ATTRIBUTES* lpSecurityAttributes, // optional
HKEY* phkResult,
DWORD* lpdwDisposition // optional
);[DllImport("CLUSAPI.dll", ExactSpelling = true)]
static extern int ClusterRegCreateKey(
IntPtr hKey, // HKEY
[MarshalAs(UnmanagedType.LPWStr)] string lpszSubKey, // LPCWSTR
uint dwOptions, // DWORD
uint samDesired, // DWORD
IntPtr lpSecurityAttributes, // SECURITY_ATTRIBUTES* optional
IntPtr phkResult, // HKEY* out
IntPtr lpdwDisposition // DWORD* optional, out
);<DllImport("CLUSAPI.dll", ExactSpelling:=True)>
Public Shared Function ClusterRegCreateKey(
hKey As IntPtr, ' HKEY
<MarshalAs(UnmanagedType.LPWStr)> lpszSubKey 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
) As Integer
End Function' hKey : HKEY
' lpszSubKey : LPCWSTR
' dwOptions : DWORD
' samDesired : DWORD
' lpSecurityAttributes : SECURITY_ATTRIBUTES* optional
' phkResult : HKEY* out
' lpdwDisposition : DWORD* optional, out
Declare PtrSafe Function ClusterRegCreateKey Lib "clusapi" ( _
ByVal hKey As LongPtr, _
ByVal lpszSubKey As LongPtr, _
ByVal dwOptions As Long, _
ByVal samDesired As Long, _
ByVal lpSecurityAttributes As LongPtr, _
ByVal phkResult As LongPtr, _
ByVal lpdwDisposition As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ClusterRegCreateKey = ctypes.windll.clusapi.ClusterRegCreateKey
ClusterRegCreateKey.restype = ctypes.c_int
ClusterRegCreateKey.argtypes = [
wintypes.HANDLE, # hKey : HKEY
wintypes.LPCWSTR, # lpszSubKey : 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
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('CLUSAPI.dll')
ClusterRegCreateKey = Fiddle::Function.new(
lib['ClusterRegCreateKey'],
[
Fiddle::TYPE_VOIDP, # hKey : HKEY
Fiddle::TYPE_VOIDP, # lpszSubKey : 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_INT)#[link(name = "clusapi")]
extern "system" {
fn ClusterRegCreateKey(
hKey: *mut core::ffi::c_void, // HKEY
lpszSubKey: *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
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("CLUSAPI.dll")]
public static extern int ClusterRegCreateKey(IntPtr hKey, [MarshalAs(UnmanagedType.LPWStr)] string lpszSubKey, uint dwOptions, uint samDesired, IntPtr lpSecurityAttributes, IntPtr phkResult, IntPtr lpdwDisposition);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CLUSAPI_ClusterRegCreateKey' -Namespace Win32 -PassThru
# $api::ClusterRegCreateKey(hKey, lpszSubKey, dwOptions, samDesired, lpSecurityAttributes, phkResult, lpdwDisposition)#uselib "CLUSAPI.dll"
#func global ClusterRegCreateKey "ClusterRegCreateKey" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; ClusterRegCreateKey hKey, lpszSubKey, dwOptions, samDesired, varptr(lpSecurityAttributes), phkResult, varptr(lpdwDisposition) ; 戻り値は stat
; hKey : HKEY -> "sptr"
; lpszSubKey : LPCWSTR -> "sptr"
; dwOptions : DWORD -> "sptr"
; samDesired : DWORD -> "sptr"
; lpSecurityAttributes : SECURITY_ATTRIBUTES* optional -> "sptr"
; phkResult : HKEY* out -> "sptr"
; lpdwDisposition : DWORD* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "CLUSAPI.dll" #cfunc global ClusterRegCreateKey "ClusterRegCreateKey" sptr, wstr, int, int, var, sptr, var ; res = ClusterRegCreateKey(hKey, lpszSubKey, dwOptions, samDesired, lpSecurityAttributes, phkResult, lpdwDisposition) ; hKey : HKEY -> "sptr" ; lpszSubKey : LPCWSTR -> "wstr" ; dwOptions : DWORD -> "int" ; samDesired : DWORD -> "int" ; lpSecurityAttributes : SECURITY_ATTRIBUTES* optional -> "var" ; phkResult : HKEY* out -> "sptr" ; lpdwDisposition : DWORD* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "CLUSAPI.dll" #cfunc global ClusterRegCreateKey "ClusterRegCreateKey" sptr, wstr, int, int, sptr, sptr, sptr ; res = ClusterRegCreateKey(hKey, lpszSubKey, dwOptions, samDesired, varptr(lpSecurityAttributes), phkResult, varptr(lpdwDisposition)) ; hKey : HKEY -> "sptr" ; lpszSubKey : LPCWSTR -> "wstr" ; dwOptions : DWORD -> "int" ; samDesired : DWORD -> "int" ; lpSecurityAttributes : SECURITY_ATTRIBUTES* optional -> "sptr" ; phkResult : HKEY* out -> "sptr" ; lpdwDisposition : DWORD* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT ClusterRegCreateKey(HKEY hKey, LPCWSTR lpszSubKey, DWORD dwOptions, DWORD samDesired, SECURITY_ATTRIBUTES* lpSecurityAttributes, HKEY* phkResult, DWORD* lpdwDisposition) #uselib "CLUSAPI.dll" #cfunc global ClusterRegCreateKey "ClusterRegCreateKey" intptr, wstr, int, int, var, intptr, var ; res = ClusterRegCreateKey(hKey, lpszSubKey, dwOptions, samDesired, lpSecurityAttributes, phkResult, lpdwDisposition) ; hKey : HKEY -> "intptr" ; lpszSubKey : LPCWSTR -> "wstr" ; dwOptions : DWORD -> "int" ; samDesired : DWORD -> "int" ; lpSecurityAttributes : SECURITY_ATTRIBUTES* optional -> "var" ; phkResult : HKEY* out -> "intptr" ; lpdwDisposition : DWORD* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT ClusterRegCreateKey(HKEY hKey, LPCWSTR lpszSubKey, DWORD dwOptions, DWORD samDesired, SECURITY_ATTRIBUTES* lpSecurityAttributes, HKEY* phkResult, DWORD* lpdwDisposition) #uselib "CLUSAPI.dll" #cfunc global ClusterRegCreateKey "ClusterRegCreateKey" intptr, wstr, int, int, intptr, intptr, intptr ; res = ClusterRegCreateKey(hKey, lpszSubKey, dwOptions, samDesired, varptr(lpSecurityAttributes), phkResult, varptr(lpdwDisposition)) ; hKey : HKEY -> "intptr" ; lpszSubKey : LPCWSTR -> "wstr" ; dwOptions : DWORD -> "int" ; samDesired : DWORD -> "int" ; lpSecurityAttributes : SECURITY_ATTRIBUTES* optional -> "intptr" ; phkResult : HKEY* out -> "intptr" ; lpdwDisposition : DWORD* optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
clusapi = windows.NewLazySystemDLL("CLUSAPI.dll")
procClusterRegCreateKey = clusapi.NewProc("ClusterRegCreateKey")
)
// hKey (HKEY), lpszSubKey (LPCWSTR), dwOptions (DWORD), samDesired (DWORD), lpSecurityAttributes (SECURITY_ATTRIBUTES* optional), phkResult (HKEY* out), lpdwDisposition (DWORD* optional, out)
r1, _, err := procClusterRegCreateKey.Call(
uintptr(hKey),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszSubKey))),
uintptr(dwOptions),
uintptr(samDesired),
uintptr(lpSecurityAttributes),
uintptr(phkResult),
uintptr(lpdwDisposition),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction ClusterRegCreateKey(
hKey: THandle; // HKEY
lpszSubKey: PWideChar; // LPCWSTR
dwOptions: DWORD; // DWORD
samDesired: DWORD; // DWORD
lpSecurityAttributes: Pointer; // SECURITY_ATTRIBUTES* optional
phkResult: Pointer; // HKEY* out
lpdwDisposition: Pointer // DWORD* optional, out
): Integer; stdcall;
external 'CLUSAPI.dll' name 'ClusterRegCreateKey';result := DllCall("CLUSAPI\ClusterRegCreateKey"
, "Ptr", hKey ; HKEY
, "WStr", lpszSubKey ; LPCWSTR
, "UInt", dwOptions ; DWORD
, "UInt", samDesired ; DWORD
, "Ptr", lpSecurityAttributes ; SECURITY_ATTRIBUTES* optional
, "Ptr", phkResult ; HKEY* out
, "Ptr", lpdwDisposition ; DWORD* optional, out
, "Int") ; return: INT●ClusterRegCreateKey(hKey, lpszSubKey, dwOptions, samDesired, lpSecurityAttributes, phkResult, lpdwDisposition) = DLL("CLUSAPI.dll", "int ClusterRegCreateKey(void*, char*, dword, dword, void*, void*, void*)")
# 呼び出し: ClusterRegCreateKey(hKey, lpszSubKey, dwOptions, samDesired, lpSecurityAttributes, phkResult, lpdwDisposition)
# hKey : HKEY -> "void*"
# lpszSubKey : LPCWSTR -> "char*"
# dwOptions : DWORD -> "dword"
# samDesired : DWORD -> "dword"
# lpSecurityAttributes : SECURITY_ATTRIBUTES* optional -> "void*"
# phkResult : HKEY* out -> "void*"
# lpdwDisposition : DWORD* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。