Win32 API 日本語リファレンス
ホームWeb.InternetExplorer › IERegCreateKeyEx

IERegCreateKeyEx

関数
IE保護モードでレジストリキーを作成する。
DLLIeframe.dll呼出規約winapi

シグネチャ

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

HRESULT IERegCreateKeyEx(
    LPCWSTR lpSubKey,
    DWORD Reserved,
    LPWSTR lpClass,   // optional
    DWORD dwOptions,
    DWORD samDesired,
    SECURITY_ATTRIBUTES* lpSecurityAttributes,   // optional
    HKEY* phkResult,
    DWORD* lpdwDisposition
);

パラメーター

名前方向説明
lpSubKeyLPCWSTRin作成または開くサブキーの名前を指す文字列を指定する。
ReservedDWORDin予約済みパラメータ。0を指定する必要がある。
lpClassLPWSTRinoptionalキーのクラス(オブジェクト型)を指す文字列を指定する。NULL可。
dwOptionsDWORDinキー作成オプションを指定する。REG_OPTION_NON_VOLATILE等のフラグ。
samDesiredDWORDinキーへの希望アクセス権を指定するアクセスマスク。KEY_WRITE等を指定する。
lpSecurityAttributesSECURITY_ATTRIBUTES*inoptionalキーのセキュリティ記述子を持つSECURITY_ATTRIBUTES構造体へのポインタ。NULL可。
phkResultHKEY*out作成または開かれたキーのハンドルを受け取るHKEYへのポインタを指定する。
lpdwDispositionDWORD*outキーが新規作成(REG_CREATED_NEW_KEY)か既存(REG_OPENED_EXISTING_KEY)かを受け取る。NULL可。

戻り値の型: HRESULT

各言語での呼び出し定義

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

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

IERegCreateKeyEx = ctypes.windll.ieframe.IERegCreateKeyEx
IERegCreateKeyEx.restype = ctypes.c_int
IERegCreateKeyEx.argtypes = [
    wintypes.LPCWSTR,  # lpSubKey : LPCWSTR
    wintypes.DWORD,  # Reserved : DWORD
    wintypes.LPCWSTR,  # lpClass : LPWSTR optional
    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* out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	ieframe = windows.NewLazySystemDLL("Ieframe.dll")
	procIERegCreateKeyEx = ieframe.NewProc("IERegCreateKeyEx")
)

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

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

typedef IERegCreateKeyExNative = Int32 Function(Pointer<Utf16>, Uint32, Pointer<Utf16>, Uint32, Uint32, Pointer<Void>, Pointer<Void>, Pointer<Uint32>);
typedef IERegCreateKeyExDart = int Function(Pointer<Utf16>, int, Pointer<Utf16>, int, int, Pointer<Void>, Pointer<Void>, Pointer<Uint32>);
final IERegCreateKeyEx = DynamicLibrary.open('Ieframe.dll')
    .lookupFunction<IERegCreateKeyExNative, IERegCreateKeyExDart>('IERegCreateKeyEx');
// lpSubKey : LPCWSTR -> Pointer<Utf16>
// Reserved : DWORD -> Uint32
// lpClass : LPWSTR optional -> Pointer<Utf16>
// dwOptions : DWORD -> Uint32
// samDesired : DWORD -> Uint32
// lpSecurityAttributes : SECURITY_ATTRIBUTES* optional -> Pointer<Void>
// phkResult : HKEY* out -> Pointer<Void>
// lpdwDisposition : DWORD* out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function IERegCreateKeyEx(
  lpSubKey: PWideChar;   // LPCWSTR
  Reserved: DWORD;   // DWORD
  lpClass: PWideChar;   // LPWSTR optional
  dwOptions: DWORD;   // DWORD
  samDesired: DWORD;   // DWORD
  lpSecurityAttributes: Pointer;   // SECURITY_ATTRIBUTES* optional
  phkResult: Pointer;   // HKEY* out
  lpdwDisposition: Pointer   // DWORD* out
): Integer; stdcall;
  external 'Ieframe.dll' name 'IERegCreateKeyEx';
import Foreign
import Foreign.C.Types
import Foreign.C.String

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

let ieregcreatekeyex =
  foreign "IERegCreateKeyEx"
    ((ptr uint16_t) @-> uint32_t @-> (ptr uint16_t) @-> uint32_t @-> uint32_t @-> (ptr void) @-> (ptr void) @-> (ptr uint32_t) @-> returning int32_t)
(* lpSubKey : LPCWSTR -> (ptr uint16_t) *)
(* Reserved : DWORD -> uint32_t *)
(* lpClass : LPWSTR optional -> (ptr uint16_t) *)
(* dwOptions : DWORD -> uint32_t *)
(* samDesired : DWORD -> uint32_t *)
(* lpSecurityAttributes : SECURITY_ATTRIBUTES* optional -> (ptr void) *)
(* phkResult : HKEY* out -> (ptr void) *)
(* lpdwDisposition : DWORD* out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library ieframe (t "Ieframe.dll"))
(cffi:use-foreign-library ieframe)

(cffi:defcfun ("IERegCreateKeyEx" iereg-create-key-ex :convention :stdcall) :int32
  (lp-sub-key (:string :encoding :utf-16le))   ; LPCWSTR
  (reserved :uint32)   ; DWORD
  (lp-class (:string :encoding :utf-16le))   ; LPWSTR optional
  (dw-options :uint32)   ; DWORD
  (sam-desired :uint32)   ; DWORD
  (lp-security-attributes :pointer)   ; SECURITY_ATTRIBUTES* optional
  (phk-result :pointer)   ; HKEY* out
  (lpdw-disposition :pointer))   ; DWORD* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $IERegCreateKeyEx = Win32::API::More->new('Ieframe',
    'int IERegCreateKeyEx(LPCWSTR lpSubKey, DWORD Reserved, LPCWSTR lpClass, DWORD dwOptions, DWORD samDesired, LPVOID lpSecurityAttributes, HANDLE phkResult, LPVOID lpdwDisposition)');
# my $ret = $IERegCreateKeyEx->Call($lpSubKey, $Reserved, $lpClass, $dwOptions, $samDesired, $lpSecurityAttributes, $phkResult, $lpdwDisposition);
# lpSubKey : LPCWSTR -> LPCWSTR
# Reserved : DWORD -> DWORD
# lpClass : LPWSTR optional -> LPCWSTR
# dwOptions : DWORD -> DWORD
# samDesired : DWORD -> DWORD
# lpSecurityAttributes : SECURITY_ATTRIBUTES* optional -> LPVOID
# phkResult : HKEY* out -> HANDLE
# lpdwDisposition : DWORD* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型