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

パラメーター

名前方向説明
hWndHWNDinoptionalUIの親となるウィンドウのハンドル。NULL可。
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 版の利用を推奨。
const std = @import("std");

extern "advpack" fn RegRestoreAllW(
    hWnd: ?*anyopaque, // HWND optional
    pszTitleString: [*c]const u16, // LPCWSTR optional
    hkBckupKey: ?*anyopaque // HKEY
) callconv(std.os.windows.WINAPI) i32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。
proc RegRestoreAllW(
    hWnd: pointer,  # HWND optional
    pszTitleString: WideCString,  # LPCWSTR optional
    hkBckupKey: pointer  # HKEY
): int32 {.importc: "RegRestoreAllW", stdcall, dynlib: "ADVPACK.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。
pragma(lib, "advpack");
extern(Windows)
int RegRestoreAllW(
    void* hWnd,   // HWND optional
    const(wchar)* pszTitleString,   // LPCWSTR optional
    void* hkBckupKey   // HKEY
);
ccall((:RegRestoreAllW, "ADVPACK.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Cwstring, Ptr{Cvoid}),
      hWnd, pszTitleString, hkBckupKey)
# hWnd : HWND optional -> Ptr{Cvoid}
# pszTitleString : LPCWSTR optional -> Cwstring
# hkBckupKey : HKEY -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。
local ffi = require("ffi")
ffi.cdef[[
int32_t RegRestoreAllW(
    void* hWnd,
    const uint16_t* pszTitleString,
    void* hkBckupKey);
]]
local advpack = ffi.load("advpack")
-- advpack.RegRestoreAllW(hWnd, pszTitleString, hkBckupKey)
-- hWnd : HWND optional
-- pszTitleString : LPCWSTR optional
-- hkBckupKey : HKEY
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。
const koffi = require('koffi');
const lib = koffi.load('ADVPACK.dll');
const RegRestoreAllW = lib.func('__stdcall', 'RegRestoreAllW', 'int32_t', ['void *', 'str16', 'void *']);
// RegRestoreAllW(hWnd, pszTitleString, hkBckupKey)
// hWnd : HWND optional -> 'void *'
// pszTitleString : LPCWSTR optional -> 'str16'
// hkBckupKey : HKEY -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("ADVPACK.dll", {
  RegRestoreAllW: { parameters: ["pointer", "buffer", "pointer"], result: "i32" },
});
// lib.symbols.RegRestoreAllW(hWnd, pszTitleString, hkBckupKey)
// hWnd : HWND optional -> "pointer"
// pszTitleString : LPCWSTR optional -> "buffer"
// hkBckupKey : HKEY -> "pointer"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t RegRestoreAllW(
    void* hWnd,
    const uint16_t* pszTitleString,
    void* hkBckupKey);
C, "ADVPACK.dll");
// $ffi->RegRestoreAllW(hWnd, pszTitleString, hkBckupKey);
// hWnd : HWND optional
// pszTitleString : LPCWSTR optional
// hkBckupKey : HKEY
// 構造体/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 Advpack extends StdCallLibrary {
    Advpack INSTANCE = Native.load("advpack", Advpack.class, W32APIOptions.UNICODE_OPTIONS);
    int RegRestoreAllW(
        Pointer hWnd,   // HWND optional
        WString pszTitleString,   // LPCWSTR optional
        Pointer hkBckupKey   // HKEY
    );
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。
@[Link("advpack")]
lib LibADVPACK
  fun RegRestoreAllW = RegRestoreAllW(
    hWnd : Void*,   # HWND optional
    pszTitleString : UInt16*,   # LPCWSTR optional
    hkBckupKey : Void*   # HKEY
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef RegRestoreAllWNative = Int32 Function(Pointer<Void>, Pointer<Utf16>, Pointer<Void>);
typedef RegRestoreAllWDart = int Function(Pointer<Void>, Pointer<Utf16>, Pointer<Void>);
final RegRestoreAllW = DynamicLibrary.open('ADVPACK.dll')
    .lookupFunction<RegRestoreAllWNative, RegRestoreAllWDart>('RegRestoreAllW');
// hWnd : HWND optional -> Pointer<Void>
// pszTitleString : LPCWSTR optional -> Pointer<Utf16>
// hkBckupKey : HKEY -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function RegRestoreAllW(
  hWnd: THandle;   // HWND optional
  pszTitleString: PWideChar;   // LPCWSTR optional
  hkBckupKey: THandle   // HKEY
): Integer; stdcall;
  external 'ADVPACK.dll' name 'RegRestoreAllW';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "RegRestoreAllW"
  c_RegRestoreAllW :: Ptr () -> CWString -> Ptr () -> IO Int32
-- hWnd : HWND optional -> Ptr ()
-- pszTitleString : LPCWSTR optional -> CWString
-- hkBckupKey : HKEY -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let regrestoreallw =
  foreign "RegRestoreAllW"
    ((ptr void) @-> (ptr uint16_t) @-> (ptr void) @-> returning int32_t)
(* hWnd : HWND optional -> (ptr void) *)
(* pszTitleString : LPCWSTR optional -> (ptr uint16_t) *)
(* hkBckupKey : HKEY -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library advpack (t "ADVPACK.dll"))
(cffi:use-foreign-library advpack)

(cffi:defcfun ("RegRestoreAllW" reg-restore-all-w :convention :stdcall) :int32
  (h-wnd :pointer)   ; HWND optional
  (psz-title-string (:string :encoding :utf-16le))   ; LPCWSTR optional
  (hk-bckup-key :pointer))   ; HKEY
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $RegRestoreAllW = Win32::API::More->new('ADVPACK',
    'int RegRestoreAllW(HANDLE hWnd, LPCWSTR pszTitleString, HANDLE hkBckupKey)');
# my $ret = $RegRestoreAllW->Call($hWnd, $pszTitleString, $hkBckupKey);
# hWnd : HWND optional -> HANDLE
# pszTitleString : LPCWSTR optional -> LPCWSTR
# hkBckupKey : HKEY -> HANDLE
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。

関連項目

文字セット違い