Win32 API 日本語リファレンス
ホームSystem.WindowsProgramming › RegRestoreAllW

RegRestoreAllW

関数
バックアップキー配下の全レジストリ値を復元する(Unicode版)。
DLLADVPACK.dll文字セットUnicode (-W)呼出規約winapi

シグネチャ

// ADVPACK.dll  (Unicode / -W)
#include <windows.h>

HRESULT RegRestoreAllW(
    HWND hWnd,   // optional
    LPCWSTR pszTitleString,   // optional
    HKEY hkBckupKey
);

パラメーター

名前方向
hWndHWNDinoptional
pszTitleStringLPCWSTRinoptional
hkBckupKeyHKEYin

戻り値の型: HRESULT

各言語での呼び出し定義

// ADVPACK.dll  (Unicode / -W)
#include <windows.h>

HRESULT RegRestoreAllW(
    HWND hWnd,   // optional
    LPCWSTR pszTitleString,   // optional
    HKEY hkBckupKey
);
[DllImport("ADVPACK.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int RegRestoreAllW(
    IntPtr hWnd,   // HWND optional
    [MarshalAs(UnmanagedType.LPWStr)] string pszTitleString,   // LPCWSTR optional
    IntPtr hkBckupKey   // HKEY
);
<DllImport("ADVPACK.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function RegRestoreAllW(
    hWnd As IntPtr,   ' HWND optional
    <MarshalAs(UnmanagedType.LPWStr)> pszTitleString As String,   ' LPCWSTR optional
    hkBckupKey As IntPtr   ' HKEY
) As Integer
End Function
' hWnd : HWND optional
' pszTitleString : LPCWSTR optional
' hkBckupKey : HKEY
Declare PtrSafe Function RegRestoreAllW Lib "advpack" ( _
    ByVal hWnd As LongPtr, _
    ByVal pszTitleString As LongPtr, _
    ByVal hkBckupKey As LongPtr) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

RegRestoreAllW = ctypes.windll.advpack.RegRestoreAllW
RegRestoreAllW.restype = ctypes.c_int
RegRestoreAllW.argtypes = [
    wintypes.HANDLE,  # hWnd : HWND optional
    wintypes.LPCWSTR,  # pszTitleString : LPCWSTR optional
    wintypes.HANDLE,  # hkBckupKey : HKEY
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('ADVPACK.dll')
RegRestoreAllW = Fiddle::Function.new(
  lib['RegRestoreAllW'],
  [
    Fiddle::TYPE_VOIDP,  # hWnd : HWND optional
    Fiddle::TYPE_VOIDP,  # pszTitleString : LPCWSTR optional
    Fiddle::TYPE_VOIDP,  # hkBckupKey : HKEY
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "advpack")]
extern "system" {
    fn RegRestoreAllW(
        hWnd: *mut core::ffi::c_void,  // HWND optional
        pszTitleString: *const u16,  // LPCWSTR optional
        hkBckupKey: *mut core::ffi::c_void  // HKEY
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("ADVPACK.dll", CharSet = CharSet.Unicode)]
public static extern int RegRestoreAllW(IntPtr hWnd, [MarshalAs(UnmanagedType.LPWStr)] string pszTitleString, IntPtr hkBckupKey);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVPACK_RegRestoreAllW' -Namespace Win32 -PassThru
# $api::RegRestoreAllW(hWnd, pszTitleString, hkBckupKey)
#uselib "ADVPACK.dll"
#func global RegRestoreAllW "RegRestoreAllW" wptr, wptr, wptr
; RegRestoreAllW hWnd, pszTitleString, hkBckupKey   ; 戻り値は stat
; hWnd : HWND optional -> "wptr"
; pszTitleString : LPCWSTR optional -> "wptr"
; hkBckupKey : HKEY -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "ADVPACK.dll"
#cfunc global RegRestoreAllW "RegRestoreAllW" sptr, wstr, sptr
; res = RegRestoreAllW(hWnd, pszTitleString, hkBckupKey)
; hWnd : HWND optional -> "sptr"
; pszTitleString : LPCWSTR optional -> "wstr"
; hkBckupKey : HKEY -> "sptr"
; HRESULT RegRestoreAllW(HWND hWnd, LPCWSTR pszTitleString, HKEY hkBckupKey)
#uselib "ADVPACK.dll"
#cfunc global RegRestoreAllW "RegRestoreAllW" intptr, wstr, intptr
; res = RegRestoreAllW(hWnd, pszTitleString, hkBckupKey)
; hWnd : HWND optional -> "intptr"
; pszTitleString : LPCWSTR optional -> "wstr"
; hkBckupKey : HKEY -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	advpack = windows.NewLazySystemDLL("ADVPACK.dll")
	procRegRestoreAllW = advpack.NewProc("RegRestoreAllW")
)

// hWnd (HWND optional), pszTitleString (LPCWSTR optional), hkBckupKey (HKEY)
r1, _, err := procRegRestoreAllW.Call(
	uintptr(hWnd),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszTitleString))),
	uintptr(hkBckupKey),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function RegRestoreAllW(
  hWnd: THandle;   // HWND optional
  pszTitleString: PWideChar;   // LPCWSTR optional
  hkBckupKey: THandle   // HKEY
): Integer; stdcall;
  external 'ADVPACK.dll' name 'RegRestoreAllW';
result := DllCall("ADVPACK\RegRestoreAllW"
    , "Ptr", hWnd   ; HWND optional
    , "WStr", pszTitleString   ; LPCWSTR optional
    , "Ptr", hkBckupKey   ; HKEY
    , "Int")   ; return: HRESULT
●RegRestoreAllW(hWnd, pszTitleString, hkBckupKey) = DLL("ADVPACK.dll", "int RegRestoreAllW(void*, char*, void*)")
# 呼び出し: RegRestoreAllW(hWnd, pszTitleString, hkBckupKey)
# hWnd : HWND optional -> "void*"
# pszTitleString : LPCWSTR optional -> "char*"
# hkBckupKey : HKEY -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。