ホーム › 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 | キーのオプション(REG_OPTION_VOLATILE等)。 |
| samDesired | DWORD | in | 新規キーに要求するアクセス権を示すアクセスマスク。 |
| lpSecurityAttributes | SECURITY_ATTRIBUTES* | inoptional | キーのセキュリティ属性。NULL可で既定の記述子を使う。 |
| phkResult | HKEY* | out | 作成または開かれたキーのハンドルを受け取るポインタ。 |
| lpdwDisposition | DWORD* | outoptional | 新規作成か既存オープンかを受け取るDWORDポインタ。NULL可。 |
戻り値の型: 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)。const std = @import("std");
extern "clusapi" fn ClusterRegCreateKey(
hKey: ?*anyopaque, // HKEY
lpszSubKey: [*c]const u16, // LPCWSTR
dwOptions: u32, // DWORD
samDesired: u32, // DWORD
lpSecurityAttributes: [*c]SECURITY_ATTRIBUTES, // SECURITY_ATTRIBUTES* optional
phkResult: ?*anyopaque, // HKEY* out
lpdwDisposition: [*c]u32 // DWORD* optional, out
) callconv(std.os.windows.WINAPI) i32;proc ClusterRegCreateKey(
hKey: pointer, # HKEY
lpszSubKey: WideCString, # LPCWSTR
dwOptions: uint32, # DWORD
samDesired: uint32, # DWORD
lpSecurityAttributes: ptr SECURITY_ATTRIBUTES, # SECURITY_ATTRIBUTES* optional
phkResult: pointer, # HKEY* out
lpdwDisposition: ptr uint32 # DWORD* optional, out
): int32 {.importc: "ClusterRegCreateKey", stdcall, dynlib: "CLUSAPI.dll".}pragma(lib, "clusapi");
extern(Windows)
int ClusterRegCreateKey(
void* hKey, // HKEY
const(wchar)* lpszSubKey, // LPCWSTR
uint dwOptions, // DWORD
uint samDesired, // DWORD
SECURITY_ATTRIBUTES* lpSecurityAttributes, // SECURITY_ATTRIBUTES* optional
void* phkResult, // HKEY* out
uint* lpdwDisposition // DWORD* optional, out
);ccall((:ClusterRegCreateKey, "CLUSAPI.dll"), stdcall, Int32,
(Ptr{Cvoid}, Cwstring, UInt32, UInt32, Ptr{SECURITY_ATTRIBUTES}, Ptr{Cvoid}, Ptr{UInt32}),
hKey, lpszSubKey, dwOptions, samDesired, lpSecurityAttributes, phkResult, lpdwDisposition)
# hKey : HKEY -> Ptr{Cvoid}
# lpszSubKey : LPCWSTR -> Cwstring
# dwOptions : DWORD -> UInt32
# samDesired : DWORD -> UInt32
# lpSecurityAttributes : SECURITY_ATTRIBUTES* optional -> Ptr{SECURITY_ATTRIBUTES}
# phkResult : HKEY* out -> Ptr{Cvoid}
# lpdwDisposition : DWORD* optional, out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t ClusterRegCreateKey(
void* hKey,
const uint16_t* lpszSubKey,
uint32_t dwOptions,
uint32_t samDesired,
void* lpSecurityAttributes,
void* phkResult,
uint32_t* lpdwDisposition);
]]
local clusapi = ffi.load("clusapi")
-- clusapi.ClusterRegCreateKey(hKey, lpszSubKey, dwOptions, samDesired, lpSecurityAttributes, phkResult, lpdwDisposition)
-- hKey : HKEY
-- lpszSubKey : LPCWSTR
-- dwOptions : DWORD
-- samDesired : DWORD
-- lpSecurityAttributes : SECURITY_ATTRIBUTES* optional
-- phkResult : HKEY* out
-- lpdwDisposition : DWORD* optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('CLUSAPI.dll');
const ClusterRegCreateKey = lib.func('__stdcall', 'ClusterRegCreateKey', 'int32_t', ['void *', 'str16', 'uint32_t', 'uint32_t', 'void *', 'void *', 'uint32_t *']);
// ClusterRegCreateKey(hKey, lpszSubKey, dwOptions, samDesired, lpSecurityAttributes, phkResult, lpdwDisposition)
// hKey : HKEY -> 'void *'
// lpszSubKey : LPCWSTR -> 'str16'
// dwOptions : DWORD -> 'uint32_t'
// samDesired : DWORD -> 'uint32_t'
// lpSecurityAttributes : SECURITY_ATTRIBUTES* optional -> 'void *'
// phkResult : HKEY* out -> 'void *'
// lpdwDisposition : DWORD* optional, out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("CLUSAPI.dll", {
ClusterRegCreateKey: { parameters: ["pointer", "buffer", "u32", "u32", "pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.ClusterRegCreateKey(hKey, lpszSubKey, dwOptions, samDesired, lpSecurityAttributes, phkResult, lpdwDisposition)
// hKey : HKEY -> "pointer"
// lpszSubKey : LPCWSTR -> "buffer"
// dwOptions : DWORD -> "u32"
// samDesired : DWORD -> "u32"
// lpSecurityAttributes : SECURITY_ATTRIBUTES* optional -> "pointer"
// phkResult : HKEY* out -> "pointer"
// lpdwDisposition : DWORD* optional, out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t ClusterRegCreateKey(
void* hKey,
const uint16_t* lpszSubKey,
uint32_t dwOptions,
uint32_t samDesired,
void* lpSecurityAttributes,
void* phkResult,
uint32_t* lpdwDisposition);
C, "CLUSAPI.dll");
// $ffi->ClusterRegCreateKey(hKey, lpszSubKey, dwOptions, samDesired, lpSecurityAttributes, phkResult, lpdwDisposition);
// hKey : HKEY
// lpszSubKey : LPCWSTR
// dwOptions : DWORD
// samDesired : DWORD
// lpSecurityAttributes : SECURITY_ATTRIBUTES* optional
// phkResult : HKEY* out
// lpdwDisposition : DWORD* optional, out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Clusapi extends StdCallLibrary {
Clusapi INSTANCE = Native.load("clusapi", Clusapi.class);
int ClusterRegCreateKey(
Pointer hKey, // HKEY
WString lpszSubKey, // LPCWSTR
int dwOptions, // DWORD
int samDesired, // DWORD
Pointer lpSecurityAttributes, // SECURITY_ATTRIBUTES* optional
Pointer phkResult, // HKEY* out
IntByReference lpdwDisposition // DWORD* optional, out
);
}@[Link("clusapi")]
lib LibCLUSAPI
fun ClusterRegCreateKey = ClusterRegCreateKey(
hKey : Void*, # HKEY
lpszSubKey : UInt16*, # LPCWSTR
dwOptions : UInt32, # DWORD
samDesired : UInt32, # DWORD
lpSecurityAttributes : SECURITY_ATTRIBUTES*, # SECURITY_ATTRIBUTES* optional
phkResult : Void*, # HKEY* out
lpdwDisposition : UInt32* # DWORD* optional, out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef ClusterRegCreateKeyNative = Int32 Function(Pointer<Void>, Pointer<Utf16>, Uint32, Uint32, Pointer<Void>, Pointer<Void>, Pointer<Uint32>);
typedef ClusterRegCreateKeyDart = int Function(Pointer<Void>, Pointer<Utf16>, int, int, Pointer<Void>, Pointer<Void>, Pointer<Uint32>);
final ClusterRegCreateKey = DynamicLibrary.open('CLUSAPI.dll')
.lookupFunction<ClusterRegCreateKeyNative, ClusterRegCreateKeyDart>('ClusterRegCreateKey');
// hKey : HKEY -> Pointer<Void>
// lpszSubKey : LPCWSTR -> Pointer<Utf16>
// dwOptions : DWORD -> Uint32
// samDesired : DWORD -> Uint32
// lpSecurityAttributes : SECURITY_ATTRIBUTES* optional -> Pointer<Void>
// phkResult : HKEY* out -> Pointer<Void>
// lpdwDisposition : DWORD* optional, out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function 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';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "ClusterRegCreateKey"
c_ClusterRegCreateKey :: Ptr () -> CWString -> Word32 -> Word32 -> Ptr () -> Ptr () -> Ptr Word32 -> IO Int32
-- hKey : HKEY -> Ptr ()
-- lpszSubKey : LPCWSTR -> CWString
-- dwOptions : DWORD -> Word32
-- samDesired : DWORD -> Word32
-- lpSecurityAttributes : SECURITY_ATTRIBUTES* optional -> Ptr ()
-- phkResult : HKEY* out -> Ptr ()
-- lpdwDisposition : DWORD* optional, out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let clusterregcreatekey =
foreign "ClusterRegCreateKey"
((ptr void) @-> (ptr uint16_t) @-> uint32_t @-> uint32_t @-> (ptr void) @-> (ptr void) @-> (ptr uint32_t) @-> returning int32_t)
(* hKey : HKEY -> (ptr void) *)
(* lpszSubKey : LPCWSTR -> (ptr uint16_t) *)
(* dwOptions : DWORD -> uint32_t *)
(* samDesired : DWORD -> uint32_t *)
(* lpSecurityAttributes : SECURITY_ATTRIBUTES* optional -> (ptr void) *)
(* phkResult : HKEY* out -> (ptr void) *)
(* lpdwDisposition : DWORD* optional, out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library clusapi (t "CLUSAPI.dll"))
(cffi:use-foreign-library clusapi)
(cffi:defcfun ("ClusterRegCreateKey" cluster-reg-create-key :convention :stdcall) :int32
(h-key :pointer) ; HKEY
(lpsz-sub-key (:string :encoding :utf-16le)) ; LPCWSTR
(dw-options :uint32) ; DWORD
(sam-desired :uint32) ; DWORD
(lp-security-attributes :pointer) ; SECURITY_ATTRIBUTES* optional
(phk-result :pointer) ; HKEY* out
(lpdw-disposition :pointer)) ; DWORD* optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ClusterRegCreateKey = Win32::API::More->new('CLUSAPI',
'int ClusterRegCreateKey(HANDLE hKey, LPCWSTR lpszSubKey, DWORD dwOptions, DWORD samDesired, LPVOID lpSecurityAttributes, HANDLE phkResult, LPVOID lpdwDisposition)');
# my $ret = $ClusterRegCreateKey->Call($hKey, $lpszSubKey, $dwOptions, $samDesired, $lpSecurityAttributes, $phkResult, $lpdwDisposition);
# hKey : HKEY -> HANDLE
# lpszSubKey : LPCWSTR -> LPCWSTR
# dwOptions : DWORD -> DWORD
# samDesired : DWORD -> DWORD
# lpSecurityAttributes : SECURITY_ATTRIBUTES* optional -> LPVOID
# phkResult : HKEY* out -> HANDLE
# lpdwDisposition : DWORD* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
類似 API
- f ClusterRegCreateKeyEx — 理由付きでクラスターレジストリのサブキーを作成または開く。