ホーム › System.Registry › RegCreateKeyTransactedA
RegCreateKeyTransactedA
関数トランザクション処理でレジストリキーを作成または開く。
シグネチャ
// ADVAPI32.dll (ANSI / -A)
#include <windows.h>
WIN32_ERROR RegCreateKeyTransactedA(
HKEY hKey,
LPCSTR lpSubKey,
DWORD Reserved, // optional
LPSTR lpClass, // optional
REG_OPEN_CREATE_OPTIONS dwOptions,
REG_SAM_FLAGS samDesired,
const SECURITY_ATTRIBUTES* lpSecurityAttributes, // optional
HKEY* phkResult,
REG_CREATE_KEY_DISPOSITION* lpdwDisposition, // optional
HANDLE hTransaction,
void* pExtendedParemeter // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hKey | HKEY | in |
| lpSubKey | LPCSTR | in |
| Reserved | DWORD | optional |
| lpClass | LPSTR | inoptional |
| dwOptions | REG_OPEN_CREATE_OPTIONS | in |
| samDesired | REG_SAM_FLAGS | in |
| lpSecurityAttributes | SECURITY_ATTRIBUTES* | inoptional |
| phkResult | HKEY* | out |
| lpdwDisposition | REG_CREATE_KEY_DISPOSITION* | outoptional |
| hTransaction | HANDLE | in |
| pExtendedParemeter | void* | optional |
戻り値の型: WIN32_ERROR
各言語での呼び出し定義
// ADVAPI32.dll (ANSI / -A)
#include <windows.h>
WIN32_ERROR RegCreateKeyTransactedA(
HKEY hKey,
LPCSTR lpSubKey,
DWORD Reserved, // optional
LPSTR lpClass, // optional
REG_OPEN_CREATE_OPTIONS dwOptions,
REG_SAM_FLAGS samDesired,
const SECURITY_ATTRIBUTES* lpSecurityAttributes, // optional
HKEY* phkResult,
REG_CREATE_KEY_DISPOSITION* lpdwDisposition, // optional
HANDLE hTransaction,
void* pExtendedParemeter // optional
);[DllImport("ADVAPI32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint RegCreateKeyTransactedA(
IntPtr hKey, // HKEY
[MarshalAs(UnmanagedType.LPStr)] string lpSubKey, // LPCSTR
uint Reserved, // DWORD optional
[MarshalAs(UnmanagedType.LPStr)] string lpClass, // LPSTR optional
uint dwOptions, // REG_OPEN_CREATE_OPTIONS
uint samDesired, // REG_SAM_FLAGS
IntPtr lpSecurityAttributes, // SECURITY_ATTRIBUTES* optional
IntPtr phkResult, // HKEY* out
IntPtr lpdwDisposition, // REG_CREATE_KEY_DISPOSITION* optional, out
IntPtr hTransaction, // HANDLE
IntPtr pExtendedParemeter // void* optional
);<DllImport("ADVAPI32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function RegCreateKeyTransactedA(
hKey As IntPtr, ' HKEY
<MarshalAs(UnmanagedType.LPStr)> lpSubKey As String, ' LPCSTR
Reserved As UInteger, ' DWORD optional
<MarshalAs(UnmanagedType.LPStr)> lpClass As String, ' LPSTR optional
dwOptions As UInteger, ' REG_OPEN_CREATE_OPTIONS
samDesired As UInteger, ' REG_SAM_FLAGS
lpSecurityAttributes As IntPtr, ' SECURITY_ATTRIBUTES* optional
phkResult As IntPtr, ' HKEY* out
lpdwDisposition As IntPtr, ' REG_CREATE_KEY_DISPOSITION* optional, out
hTransaction As IntPtr, ' HANDLE
pExtendedParemeter As IntPtr ' void* optional
) As UInteger
End Function' hKey : HKEY
' lpSubKey : LPCSTR
' Reserved : DWORD optional
' lpClass : LPSTR optional
' dwOptions : REG_OPEN_CREATE_OPTIONS
' samDesired : REG_SAM_FLAGS
' lpSecurityAttributes : SECURITY_ATTRIBUTES* optional
' phkResult : HKEY* out
' lpdwDisposition : REG_CREATE_KEY_DISPOSITION* optional, out
' hTransaction : HANDLE
' pExtendedParemeter : void* optional
Declare PtrSafe Function RegCreateKeyTransactedA Lib "advapi32" ( _
ByVal hKey As LongPtr, _
ByVal lpSubKey As String, _
ByVal Reserved As Long, _
ByVal lpClass As String, _
ByVal dwOptions As Long, _
ByVal samDesired As Long, _
ByVal lpSecurityAttributes As LongPtr, _
ByVal phkResult As LongPtr, _
ByVal lpdwDisposition As LongPtr, _
ByVal hTransaction As LongPtr, _
ByVal pExtendedParemeter As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
RegCreateKeyTransactedA = ctypes.windll.advapi32.RegCreateKeyTransactedA
RegCreateKeyTransactedA.restype = wintypes.DWORD
RegCreateKeyTransactedA.argtypes = [
wintypes.HANDLE, # hKey : HKEY
wintypes.LPCSTR, # lpSubKey : LPCSTR
wintypes.DWORD, # Reserved : DWORD optional
wintypes.LPCSTR, # lpClass : LPSTR optional
wintypes.DWORD, # dwOptions : REG_OPEN_CREATE_OPTIONS
wintypes.DWORD, # samDesired : REG_SAM_FLAGS
ctypes.c_void_p, # lpSecurityAttributes : SECURITY_ATTRIBUTES* optional
ctypes.c_void_p, # phkResult : HKEY* out
ctypes.c_void_p, # lpdwDisposition : REG_CREATE_KEY_DISPOSITION* optional, out
wintypes.HANDLE, # hTransaction : HANDLE
ctypes.POINTER(None), # pExtendedParemeter : void* optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ADVAPI32.dll')
RegCreateKeyTransactedA = Fiddle::Function.new(
lib['RegCreateKeyTransactedA'],
[
Fiddle::TYPE_VOIDP, # hKey : HKEY
Fiddle::TYPE_VOIDP, # lpSubKey : LPCSTR
-Fiddle::TYPE_INT, # Reserved : DWORD optional
Fiddle::TYPE_VOIDP, # lpClass : LPSTR optional
-Fiddle::TYPE_INT, # dwOptions : REG_OPEN_CREATE_OPTIONS
-Fiddle::TYPE_INT, # samDesired : REG_SAM_FLAGS
Fiddle::TYPE_VOIDP, # lpSecurityAttributes : SECURITY_ATTRIBUTES* optional
Fiddle::TYPE_VOIDP, # phkResult : HKEY* out
Fiddle::TYPE_VOIDP, # lpdwDisposition : REG_CREATE_KEY_DISPOSITION* optional, out
Fiddle::TYPE_VOIDP, # hTransaction : HANDLE
Fiddle::TYPE_VOIDP, # pExtendedParemeter : void* optional
],
-Fiddle::TYPE_INT)#[link(name = "advapi32")]
extern "system" {
fn RegCreateKeyTransactedA(
hKey: *mut core::ffi::c_void, // HKEY
lpSubKey: *const u8, // LPCSTR
Reserved: u32, // DWORD optional
lpClass: *mut u8, // LPSTR optional
dwOptions: u32, // REG_OPEN_CREATE_OPTIONS
samDesired: u32, // REG_SAM_FLAGS
lpSecurityAttributes: *const SECURITY_ATTRIBUTES, // SECURITY_ATTRIBUTES* optional
phkResult: *mut *mut core::ffi::c_void, // HKEY* out
lpdwDisposition: *mut u32, // REG_CREATE_KEY_DISPOSITION* optional, out
hTransaction: *mut core::ffi::c_void, // HANDLE
pExtendedParemeter: *mut () // void* optional
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ADVAPI32.dll", CharSet = CharSet.Ansi)]
public static extern uint RegCreateKeyTransactedA(IntPtr hKey, [MarshalAs(UnmanagedType.LPStr)] string lpSubKey, uint Reserved, [MarshalAs(UnmanagedType.LPStr)] string lpClass, uint dwOptions, uint samDesired, IntPtr lpSecurityAttributes, IntPtr phkResult, IntPtr lpdwDisposition, IntPtr hTransaction, IntPtr pExtendedParemeter);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_RegCreateKeyTransactedA' -Namespace Win32 -PassThru
# $api::RegCreateKeyTransactedA(hKey, lpSubKey, Reserved, lpClass, dwOptions, samDesired, lpSecurityAttributes, phkResult, lpdwDisposition, hTransaction, pExtendedParemeter)#uselib "ADVAPI32.dll"
#func global RegCreateKeyTransactedA "RegCreateKeyTransactedA" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; RegCreateKeyTransactedA hKey, lpSubKey, Reserved, lpClass, dwOptions, samDesired, varptr(lpSecurityAttributes), phkResult, lpdwDisposition, hTransaction, pExtendedParemeter ; 戻り値は stat
; hKey : HKEY -> "sptr"
; lpSubKey : LPCSTR -> "sptr"
; Reserved : DWORD optional -> "sptr"
; lpClass : LPSTR optional -> "sptr"
; dwOptions : REG_OPEN_CREATE_OPTIONS -> "sptr"
; samDesired : REG_SAM_FLAGS -> "sptr"
; lpSecurityAttributes : SECURITY_ATTRIBUTES* optional -> "sptr"
; phkResult : HKEY* out -> "sptr"
; lpdwDisposition : REG_CREATE_KEY_DISPOSITION* optional, out -> "sptr"
; hTransaction : HANDLE -> "sptr"
; pExtendedParemeter : void* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "ADVAPI32.dll" #cfunc global RegCreateKeyTransactedA "RegCreateKeyTransactedA" sptr, str, int, str, int, int, var, sptr, int, sptr, sptr ; res = RegCreateKeyTransactedA(hKey, lpSubKey, Reserved, lpClass, dwOptions, samDesired, lpSecurityAttributes, phkResult, lpdwDisposition, hTransaction, pExtendedParemeter) ; hKey : HKEY -> "sptr" ; lpSubKey : LPCSTR -> "str" ; Reserved : DWORD optional -> "int" ; lpClass : LPSTR optional -> "str" ; dwOptions : REG_OPEN_CREATE_OPTIONS -> "int" ; samDesired : REG_SAM_FLAGS -> "int" ; lpSecurityAttributes : SECURITY_ATTRIBUTES* optional -> "var" ; phkResult : HKEY* out -> "sptr" ; lpdwDisposition : REG_CREATE_KEY_DISPOSITION* optional, out -> "int" ; hTransaction : HANDLE -> "sptr" ; pExtendedParemeter : void* optional -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ADVAPI32.dll" #cfunc global RegCreateKeyTransactedA "RegCreateKeyTransactedA" sptr, str, int, str, int, int, sptr, sptr, int, sptr, sptr ; res = RegCreateKeyTransactedA(hKey, lpSubKey, Reserved, lpClass, dwOptions, samDesired, varptr(lpSecurityAttributes), phkResult, lpdwDisposition, hTransaction, pExtendedParemeter) ; hKey : HKEY -> "sptr" ; lpSubKey : LPCSTR -> "str" ; Reserved : DWORD optional -> "int" ; lpClass : LPSTR optional -> "str" ; dwOptions : REG_OPEN_CREATE_OPTIONS -> "int" ; samDesired : REG_SAM_FLAGS -> "int" ; lpSecurityAttributes : SECURITY_ATTRIBUTES* optional -> "sptr" ; phkResult : HKEY* out -> "sptr" ; lpdwDisposition : REG_CREATE_KEY_DISPOSITION* optional, out -> "int" ; hTransaction : HANDLE -> "sptr" ; pExtendedParemeter : void* optional -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; WIN32_ERROR RegCreateKeyTransactedA(HKEY hKey, LPCSTR lpSubKey, DWORD Reserved, LPSTR lpClass, REG_OPEN_CREATE_OPTIONS dwOptions, REG_SAM_FLAGS samDesired, SECURITY_ATTRIBUTES* lpSecurityAttributes, HKEY* phkResult, REG_CREATE_KEY_DISPOSITION* lpdwDisposition, HANDLE hTransaction, void* pExtendedParemeter) #uselib "ADVAPI32.dll" #cfunc global RegCreateKeyTransactedA "RegCreateKeyTransactedA" intptr, str, int, str, int, int, var, intptr, int, intptr, intptr ; res = RegCreateKeyTransactedA(hKey, lpSubKey, Reserved, lpClass, dwOptions, samDesired, lpSecurityAttributes, phkResult, lpdwDisposition, hTransaction, pExtendedParemeter) ; hKey : HKEY -> "intptr" ; lpSubKey : LPCSTR -> "str" ; Reserved : DWORD optional -> "int" ; lpClass : LPSTR optional -> "str" ; dwOptions : REG_OPEN_CREATE_OPTIONS -> "int" ; samDesired : REG_SAM_FLAGS -> "int" ; lpSecurityAttributes : SECURITY_ATTRIBUTES* optional -> "var" ; phkResult : HKEY* out -> "intptr" ; lpdwDisposition : REG_CREATE_KEY_DISPOSITION* optional, out -> "int" ; hTransaction : HANDLE -> "intptr" ; pExtendedParemeter : void* optional -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; WIN32_ERROR RegCreateKeyTransactedA(HKEY hKey, LPCSTR lpSubKey, DWORD Reserved, LPSTR lpClass, REG_OPEN_CREATE_OPTIONS dwOptions, REG_SAM_FLAGS samDesired, SECURITY_ATTRIBUTES* lpSecurityAttributes, HKEY* phkResult, REG_CREATE_KEY_DISPOSITION* lpdwDisposition, HANDLE hTransaction, void* pExtendedParemeter) #uselib "ADVAPI32.dll" #cfunc global RegCreateKeyTransactedA "RegCreateKeyTransactedA" intptr, str, int, str, int, int, intptr, intptr, int, intptr, intptr ; res = RegCreateKeyTransactedA(hKey, lpSubKey, Reserved, lpClass, dwOptions, samDesired, varptr(lpSecurityAttributes), phkResult, lpdwDisposition, hTransaction, pExtendedParemeter) ; hKey : HKEY -> "intptr" ; lpSubKey : LPCSTR -> "str" ; Reserved : DWORD optional -> "int" ; lpClass : LPSTR optional -> "str" ; dwOptions : REG_OPEN_CREATE_OPTIONS -> "int" ; samDesired : REG_SAM_FLAGS -> "int" ; lpSecurityAttributes : SECURITY_ATTRIBUTES* optional -> "intptr" ; phkResult : HKEY* out -> "intptr" ; lpdwDisposition : REG_CREATE_KEY_DISPOSITION* optional, out -> "int" ; hTransaction : HANDLE -> "intptr" ; pExtendedParemeter : void* optional -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
procRegCreateKeyTransactedA = advapi32.NewProc("RegCreateKeyTransactedA")
)
// hKey (HKEY), lpSubKey (LPCSTR), Reserved (DWORD optional), lpClass (LPSTR optional), dwOptions (REG_OPEN_CREATE_OPTIONS), samDesired (REG_SAM_FLAGS), lpSecurityAttributes (SECURITY_ATTRIBUTES* optional), phkResult (HKEY* out), lpdwDisposition (REG_CREATE_KEY_DISPOSITION* optional, out), hTransaction (HANDLE), pExtendedParemeter (void* optional)
r1, _, err := procRegCreateKeyTransactedA.Call(
uintptr(hKey),
uintptr(unsafe.Pointer(windows.BytePtrFromString(lpSubKey))),
uintptr(Reserved),
uintptr(unsafe.Pointer(windows.BytePtrFromString(lpClass))),
uintptr(dwOptions),
uintptr(samDesired),
uintptr(lpSecurityAttributes),
uintptr(phkResult),
uintptr(lpdwDisposition),
uintptr(hTransaction),
uintptr(pExtendedParemeter),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // WIN32_ERRORfunction RegCreateKeyTransactedA(
hKey: THandle; // HKEY
lpSubKey: PAnsiChar; // LPCSTR
Reserved: DWORD; // DWORD optional
lpClass: PAnsiChar; // LPSTR optional
dwOptions: DWORD; // REG_OPEN_CREATE_OPTIONS
samDesired: DWORD; // REG_SAM_FLAGS
lpSecurityAttributes: Pointer; // SECURITY_ATTRIBUTES* optional
phkResult: Pointer; // HKEY* out
lpdwDisposition: Pointer; // REG_CREATE_KEY_DISPOSITION* optional, out
hTransaction: THandle; // HANDLE
pExtendedParemeter: Pointer // void* optional
): DWORD; stdcall;
external 'ADVAPI32.dll' name 'RegCreateKeyTransactedA';result := DllCall("ADVAPI32\RegCreateKeyTransactedA"
, "Ptr", hKey ; HKEY
, "AStr", lpSubKey ; LPCSTR
, "UInt", Reserved ; DWORD optional
, "AStr", lpClass ; LPSTR optional
, "UInt", dwOptions ; REG_OPEN_CREATE_OPTIONS
, "UInt", samDesired ; REG_SAM_FLAGS
, "Ptr", lpSecurityAttributes ; SECURITY_ATTRIBUTES* optional
, "Ptr", phkResult ; HKEY* out
, "Ptr", lpdwDisposition ; REG_CREATE_KEY_DISPOSITION* optional, out
, "Ptr", hTransaction ; HANDLE
, "Ptr", pExtendedParemeter ; void* optional
, "UInt") ; return: WIN32_ERROR●RegCreateKeyTransactedA(hKey, lpSubKey, Reserved, lpClass, dwOptions, samDesired, lpSecurityAttributes, phkResult, lpdwDisposition, hTransaction, pExtendedParemeter) = DLL("ADVAPI32.dll", "dword RegCreateKeyTransactedA(void*, char*, dword, char*, dword, dword, void*, void*, void*, void*, void*)")
# 呼び出し: RegCreateKeyTransactedA(hKey, lpSubKey, Reserved, lpClass, dwOptions, samDesired, lpSecurityAttributes, phkResult, lpdwDisposition, hTransaction, pExtendedParemeter)
# hKey : HKEY -> "void*"
# lpSubKey : LPCSTR -> "char*"
# Reserved : DWORD optional -> "dword"
# lpClass : LPSTR optional -> "char*"
# dwOptions : REG_OPEN_CREATE_OPTIONS -> "dword"
# samDesired : REG_SAM_FLAGS -> "dword"
# lpSecurityAttributes : SECURITY_ATTRIBUTES* optional -> "void*"
# phkResult : HKEY* out -> "void*"
# lpdwDisposition : REG_CREATE_KEY_DISPOSITION* optional, out -> "void*"
# hTransaction : HANDLE -> "void*"
# pExtendedParemeter : void* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。