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キーのオプション(REG_OPTION_VOLATILE等)。
samDesiredDWORDin新規キーに要求するアクセス権を示すアクセスマスク。
lpSecurityAttributesSECURITY_ATTRIBUTES*inoptionalキーのセキュリティ属性。NULL可で既定の記述子を使う。
phkResultHKEY*out作成または開かれたキーのハンドルを受け取るポインタ。
lpdwDispositionDWORD*outoptional新規作成か既存オープンかを受け取るDWORDポインタ。NULL可。
lpszReasonLPCWSTRinoptional操作理由を示すワイド文字列。監査ログ用でNULL可。

戻り値の型: 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)。
const std = @import("std");

extern "clusapi" fn ClusterRegCreateKeyEx(
    hKey: ?*anyopaque, // HKEY
    lpSubKey: [*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
    lpszReason: [*c]const u16 // LPCWSTR optional
) callconv(std.os.windows.WINAPI) i32;
proc ClusterRegCreateKeyEx(
    hKey: pointer,  # HKEY
    lpSubKey: 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
    lpszReason: WideCString  # LPCWSTR optional
): int32 {.importc: "ClusterRegCreateKeyEx", stdcall, dynlib: "CLUSAPI.dll".}
pragma(lib, "clusapi");
extern(Windows)
int ClusterRegCreateKeyEx(
    void* hKey,   // HKEY
    const(wchar)* lpSubKey,   // LPCWSTR
    uint dwOptions,   // DWORD
    uint samDesired,   // DWORD
    SECURITY_ATTRIBUTES* lpSecurityAttributes,   // SECURITY_ATTRIBUTES* optional
    void* phkResult,   // HKEY* out
    uint* lpdwDisposition,   // DWORD* optional, out
    const(wchar)* lpszReason   // LPCWSTR optional
);
ccall((:ClusterRegCreateKeyEx, "CLUSAPI.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Cwstring, UInt32, UInt32, Ptr{SECURITY_ATTRIBUTES}, Ptr{Cvoid}, Ptr{UInt32}, Cwstring),
      hKey, lpSubKey, dwOptions, samDesired, lpSecurityAttributes, phkResult, lpdwDisposition, lpszReason)
# hKey : HKEY -> Ptr{Cvoid}
# lpSubKey : 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}
# lpszReason : LPCWSTR optional -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t ClusterRegCreateKeyEx(
    void* hKey,
    const uint16_t* lpSubKey,
    uint32_t dwOptions,
    uint32_t samDesired,
    void* lpSecurityAttributes,
    void* phkResult,
    uint32_t* lpdwDisposition,
    const uint16_t* lpszReason);
]]
local clusapi = ffi.load("clusapi")
-- clusapi.ClusterRegCreateKeyEx(hKey, lpSubKey, dwOptions, samDesired, lpSecurityAttributes, phkResult, lpdwDisposition, lpszReason)
-- hKey : HKEY
-- lpSubKey : LPCWSTR
-- dwOptions : DWORD
-- samDesired : DWORD
-- lpSecurityAttributes : SECURITY_ATTRIBUTES* optional
-- phkResult : HKEY* out
-- lpdwDisposition : DWORD* optional, out
-- lpszReason : LPCWSTR optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('CLUSAPI.dll');
const ClusterRegCreateKeyEx = lib.func('__stdcall', 'ClusterRegCreateKeyEx', 'int32_t', ['void *', 'str16', 'uint32_t', 'uint32_t', 'void *', 'void *', 'uint32_t *', 'str16']);
// ClusterRegCreateKeyEx(hKey, lpSubKey, dwOptions, samDesired, lpSecurityAttributes, phkResult, lpdwDisposition, lpszReason)
// hKey : HKEY -> 'void *'
// lpSubKey : 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 *'
// lpszReason : LPCWSTR optional -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("CLUSAPI.dll", {
  ClusterRegCreateKeyEx: { parameters: ["pointer", "buffer", "u32", "u32", "pointer", "pointer", "pointer", "buffer"], result: "i32" },
});
// lib.symbols.ClusterRegCreateKeyEx(hKey, lpSubKey, dwOptions, samDesired, lpSecurityAttributes, phkResult, lpdwDisposition, lpszReason)
// hKey : HKEY -> "pointer"
// lpSubKey : LPCWSTR -> "buffer"
// dwOptions : DWORD -> "u32"
// samDesired : DWORD -> "u32"
// lpSecurityAttributes : SECURITY_ATTRIBUTES* optional -> "pointer"
// phkResult : HKEY* out -> "pointer"
// lpdwDisposition : DWORD* optional, out -> "pointer"
// lpszReason : LPCWSTR optional -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t ClusterRegCreateKeyEx(
    void* hKey,
    const uint16_t* lpSubKey,
    uint32_t dwOptions,
    uint32_t samDesired,
    void* lpSecurityAttributes,
    void* phkResult,
    uint32_t* lpdwDisposition,
    const uint16_t* lpszReason);
C, "CLUSAPI.dll");
// $ffi->ClusterRegCreateKeyEx(hKey, lpSubKey, dwOptions, samDesired, lpSecurityAttributes, phkResult, lpdwDisposition, lpszReason);
// hKey : HKEY
// lpSubKey : LPCWSTR
// dwOptions : DWORD
// samDesired : DWORD
// lpSecurityAttributes : SECURITY_ATTRIBUTES* optional
// phkResult : HKEY* out
// lpdwDisposition : DWORD* optional, out
// lpszReason : LPCWSTR optional
// 構造体/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 ClusterRegCreateKeyEx(
        Pointer hKey,   // HKEY
        WString lpSubKey,   // LPCWSTR
        int dwOptions,   // DWORD
        int samDesired,   // DWORD
        Pointer lpSecurityAttributes,   // SECURITY_ATTRIBUTES* optional
        Pointer phkResult,   // HKEY* out
        IntByReference lpdwDisposition,   // DWORD* optional, out
        WString lpszReason   // LPCWSTR optional
    );
}
@[Link("clusapi")]
lib LibCLUSAPI
  fun ClusterRegCreateKeyEx = ClusterRegCreateKeyEx(
    hKey : Void*,   # HKEY
    lpSubKey : UInt16*,   # LPCWSTR
    dwOptions : UInt32,   # DWORD
    samDesired : UInt32,   # DWORD
    lpSecurityAttributes : SECURITY_ATTRIBUTES*,   # SECURITY_ATTRIBUTES* optional
    phkResult : Void*,   # HKEY* out
    lpdwDisposition : UInt32*,   # DWORD* optional, out
    lpszReason : UInt16*   # LPCWSTR optional
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef ClusterRegCreateKeyExNative = Int32 Function(Pointer<Void>, Pointer<Utf16>, Uint32, Uint32, Pointer<Void>, Pointer<Void>, Pointer<Uint32>, Pointer<Utf16>);
typedef ClusterRegCreateKeyExDart = int Function(Pointer<Void>, Pointer<Utf16>, int, int, Pointer<Void>, Pointer<Void>, Pointer<Uint32>, Pointer<Utf16>);
final ClusterRegCreateKeyEx = DynamicLibrary.open('CLUSAPI.dll')
    .lookupFunction<ClusterRegCreateKeyExNative, ClusterRegCreateKeyExDart>('ClusterRegCreateKeyEx');
// hKey : HKEY -> Pointer<Void>
// lpSubKey : 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>
// lpszReason : LPCWSTR optional -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
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';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "ClusterRegCreateKeyEx"
  c_ClusterRegCreateKeyEx :: Ptr () -> CWString -> Word32 -> Word32 -> Ptr () -> Ptr () -> Ptr Word32 -> CWString -> IO Int32
-- hKey : HKEY -> Ptr ()
-- lpSubKey : LPCWSTR -> CWString
-- dwOptions : DWORD -> Word32
-- samDesired : DWORD -> Word32
-- lpSecurityAttributes : SECURITY_ATTRIBUTES* optional -> Ptr ()
-- phkResult : HKEY* out -> Ptr ()
-- lpdwDisposition : DWORD* optional, out -> Ptr Word32
-- lpszReason : LPCWSTR optional -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let clusterregcreatekeyex =
  foreign "ClusterRegCreateKeyEx"
    ((ptr void) @-> (ptr uint16_t) @-> uint32_t @-> uint32_t @-> (ptr void) @-> (ptr void) @-> (ptr uint32_t) @-> (ptr uint16_t) @-> returning int32_t)
(* hKey : HKEY -> (ptr void) *)
(* lpSubKey : 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) *)
(* lpszReason : LPCWSTR optional -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library clusapi (t "CLUSAPI.dll"))
(cffi:use-foreign-library clusapi)

(cffi:defcfun ("ClusterRegCreateKeyEx" cluster-reg-create-key-ex :convention :stdcall) :int32
  (h-key :pointer)   ; HKEY
  (lp-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
  (lpsz-reason (:string :encoding :utf-16le)))   ; LPCWSTR optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $ClusterRegCreateKeyEx = Win32::API::More->new('CLUSAPI',
    'int ClusterRegCreateKeyEx(HANDLE hKey, LPCWSTR lpSubKey, DWORD dwOptions, DWORD samDesired, LPVOID lpSecurityAttributes, HANDLE phkResult, LPVOID lpdwDisposition, LPCWSTR lpszReason)');
# my $ret = $ClusterRegCreateKeyEx->Call($hKey, $lpSubKey, $dwOptions, $samDesired, $lpSecurityAttributes, $phkResult, $lpdwDisposition, $lpszReason);
# hKey : HKEY -> HANDLE
# lpSubKey : LPCWSTR -> LPCWSTR
# dwOptions : DWORD -> DWORD
# samDesired : DWORD -> DWORD
# lpSecurityAttributes : SECURITY_ATTRIBUTES* optional -> LPVOID
# phkResult : HKEY* out -> HANDLE
# lpdwDisposition : DWORD* optional, out -> LPVOID
# lpszReason : LPCWSTR optional -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

類似 API
使用する型