SHCopyKeyA
関数レジストリキーのサブキーと値を別のキーへ複製する。
シグネチャ
// SHLWAPI.dll (ANSI / -A)
#include <windows.h>
WIN32_ERROR SHCopyKeyA(
HKEY hkeySrc,
LPCSTR pszSrcSubKey, // optional
HKEY hkeyDest,
DWORD fReserved // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hkeySrc | HKEY | in | コピー元の開いたレジストリキーのハンドル。 |
| pszSrcSubKey | LPCSTR | inoptional | コピー元のサブキー名。NULL可でhkeySrc自身を対象とする。 |
| hkeyDest | HKEY | in | コピー先の開いたレジストリキーのハンドル。 |
| fReserved | DWORD | optional | 予約済み。0を指定する。 |
戻り値の型: WIN32_ERROR
各言語での呼び出し定義
// SHLWAPI.dll (ANSI / -A)
#include <windows.h>
WIN32_ERROR SHCopyKeyA(
HKEY hkeySrc,
LPCSTR pszSrcSubKey, // optional
HKEY hkeyDest,
DWORD fReserved // optional
);[DllImport("SHLWAPI.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint SHCopyKeyA(
IntPtr hkeySrc, // HKEY
[MarshalAs(UnmanagedType.LPStr)] string pszSrcSubKey, // LPCSTR optional
IntPtr hkeyDest, // HKEY
uint fReserved // DWORD optional
);<DllImport("SHLWAPI.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function SHCopyKeyA(
hkeySrc As IntPtr, ' HKEY
<MarshalAs(UnmanagedType.LPStr)> pszSrcSubKey As String, ' LPCSTR optional
hkeyDest As IntPtr, ' HKEY
fReserved As UInteger ' DWORD optional
) As UInteger
End Function' hkeySrc : HKEY
' pszSrcSubKey : LPCSTR optional
' hkeyDest : HKEY
' fReserved : DWORD optional
Declare PtrSafe Function SHCopyKeyA Lib "shlwapi" ( _
ByVal hkeySrc As LongPtr, _
ByVal pszSrcSubKey As String, _
ByVal hkeyDest As LongPtr, _
ByVal fReserved As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SHCopyKeyA = ctypes.windll.shlwapi.SHCopyKeyA
SHCopyKeyA.restype = wintypes.DWORD
SHCopyKeyA.argtypes = [
wintypes.HANDLE, # hkeySrc : HKEY
wintypes.LPCSTR, # pszSrcSubKey : LPCSTR optional
wintypes.HANDLE, # hkeyDest : HKEY
wintypes.DWORD, # fReserved : DWORD optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SHLWAPI.dll')
SHCopyKeyA = Fiddle::Function.new(
lib['SHCopyKeyA'],
[
Fiddle::TYPE_VOIDP, # hkeySrc : HKEY
Fiddle::TYPE_VOIDP, # pszSrcSubKey : LPCSTR optional
Fiddle::TYPE_VOIDP, # hkeyDest : HKEY
-Fiddle::TYPE_INT, # fReserved : DWORD optional
],
-Fiddle::TYPE_INT)#[link(name = "shlwapi")]
extern "system" {
fn SHCopyKeyA(
hkeySrc: *mut core::ffi::c_void, // HKEY
pszSrcSubKey: *const u8, // LPCSTR optional
hkeyDest: *mut core::ffi::c_void, // HKEY
fReserved: u32 // DWORD optional
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("SHLWAPI.dll", CharSet = CharSet.Ansi)]
public static extern uint SHCopyKeyA(IntPtr hkeySrc, [MarshalAs(UnmanagedType.LPStr)] string pszSrcSubKey, IntPtr hkeyDest, uint fReserved);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHLWAPI_SHCopyKeyA' -Namespace Win32 -PassThru
# $api::SHCopyKeyA(hkeySrc, pszSrcSubKey, hkeyDest, fReserved)#uselib "SHLWAPI.dll"
#func global SHCopyKeyA "SHCopyKeyA" sptr, sptr, sptr, sptr
; SHCopyKeyA hkeySrc, pszSrcSubKey, hkeyDest, fReserved ; 戻り値は stat
; hkeySrc : HKEY -> "sptr"
; pszSrcSubKey : LPCSTR optional -> "sptr"
; hkeyDest : HKEY -> "sptr"
; fReserved : DWORD optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "SHLWAPI.dll"
#cfunc global SHCopyKeyA "SHCopyKeyA" sptr, str, sptr, int
; res = SHCopyKeyA(hkeySrc, pszSrcSubKey, hkeyDest, fReserved)
; hkeySrc : HKEY -> "sptr"
; pszSrcSubKey : LPCSTR optional -> "str"
; hkeyDest : HKEY -> "sptr"
; fReserved : DWORD optional -> "int"; WIN32_ERROR SHCopyKeyA(HKEY hkeySrc, LPCSTR pszSrcSubKey, HKEY hkeyDest, DWORD fReserved)
#uselib "SHLWAPI.dll"
#cfunc global SHCopyKeyA "SHCopyKeyA" intptr, str, intptr, int
; res = SHCopyKeyA(hkeySrc, pszSrcSubKey, hkeyDest, fReserved)
; hkeySrc : HKEY -> "intptr"
; pszSrcSubKey : LPCSTR optional -> "str"
; hkeyDest : HKEY -> "intptr"
; fReserved : DWORD optional -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
shlwapi = windows.NewLazySystemDLL("SHLWAPI.dll")
procSHCopyKeyA = shlwapi.NewProc("SHCopyKeyA")
)
// hkeySrc (HKEY), pszSrcSubKey (LPCSTR optional), hkeyDest (HKEY), fReserved (DWORD optional)
r1, _, err := procSHCopyKeyA.Call(
uintptr(hkeySrc),
uintptr(unsafe.Pointer(windows.BytePtrFromString(pszSrcSubKey))),
uintptr(hkeyDest),
uintptr(fReserved),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // WIN32_ERRORfunction SHCopyKeyA(
hkeySrc: THandle; // HKEY
pszSrcSubKey: PAnsiChar; // LPCSTR optional
hkeyDest: THandle; // HKEY
fReserved: DWORD // DWORD optional
): DWORD; stdcall;
external 'SHLWAPI.dll' name 'SHCopyKeyA';result := DllCall("SHLWAPI\SHCopyKeyA"
, "Ptr", hkeySrc ; HKEY
, "AStr", pszSrcSubKey ; LPCSTR optional
, "Ptr", hkeyDest ; HKEY
, "UInt", fReserved ; DWORD optional
, "UInt") ; return: WIN32_ERROR●SHCopyKeyA(hkeySrc, pszSrcSubKey, hkeyDest, fReserved) = DLL("SHLWAPI.dll", "dword SHCopyKeyA(void*, char*, void*, dword)")
# 呼び出し: SHCopyKeyA(hkeySrc, pszSrcSubKey, hkeyDest, fReserved)
# hkeySrc : HKEY -> "void*"
# pszSrcSubKey : LPCSTR optional -> "char*"
# hkeyDest : HKEY -> "void*"
# fReserved : DWORD optional -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。