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)。