ホーム › System.WindowsProgramming › RegSaveRestoreW
RegSaveRestoreW
関数レジストリ値の保存または復元を行う(Unicode版)。
シグネチャ
// ADVPACK.dll (Unicode / -W)
#include <windows.h>
HRESULT RegSaveRestoreW(
HWND hWnd,
LPCWSTR pszTitleString,
HKEY hkBckupKey,
LPCWSTR pcszRootKey,
LPCWSTR pcszSubKey,
LPCWSTR pcszValueName,
DWORD dwFlags
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hWnd | HWND | in |
| pszTitleString | LPCWSTR | in |
| hkBckupKey | HKEY | in |
| pcszRootKey | LPCWSTR | in |
| pcszSubKey | LPCWSTR | in |
| pcszValueName | LPCWSTR | in |
| dwFlags | DWORD | in |
戻り値の型: HRESULT
各言語での呼び出し定義
// ADVPACK.dll (Unicode / -W)
#include <windows.h>
HRESULT RegSaveRestoreW(
HWND hWnd,
LPCWSTR pszTitleString,
HKEY hkBckupKey,
LPCWSTR pcszRootKey,
LPCWSTR pcszSubKey,
LPCWSTR pcszValueName,
DWORD dwFlags
);[DllImport("ADVPACK.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int RegSaveRestoreW(
IntPtr hWnd, // HWND
[MarshalAs(UnmanagedType.LPWStr)] string pszTitleString, // LPCWSTR
IntPtr hkBckupKey, // HKEY
[MarshalAs(UnmanagedType.LPWStr)] string pcszRootKey, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string pcszSubKey, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string pcszValueName, // LPCWSTR
uint dwFlags // DWORD
);<DllImport("ADVPACK.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function RegSaveRestoreW(
hWnd As IntPtr, ' HWND
<MarshalAs(UnmanagedType.LPWStr)> pszTitleString As String, ' LPCWSTR
hkBckupKey As IntPtr, ' HKEY
<MarshalAs(UnmanagedType.LPWStr)> pcszRootKey As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> pcszSubKey As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> pcszValueName As String, ' LPCWSTR
dwFlags As UInteger ' DWORD
) As Integer
End Function' hWnd : HWND
' pszTitleString : LPCWSTR
' hkBckupKey : HKEY
' pcszRootKey : LPCWSTR
' pcszSubKey : LPCWSTR
' pcszValueName : LPCWSTR
' dwFlags : DWORD
Declare PtrSafe Function RegSaveRestoreW Lib "advpack" ( _
ByVal hWnd As LongPtr, _
ByVal pszTitleString As LongPtr, _
ByVal hkBckupKey As LongPtr, _
ByVal pcszRootKey As LongPtr, _
ByVal pcszSubKey As LongPtr, _
ByVal pcszValueName As LongPtr, _
ByVal dwFlags As Long) 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
RegSaveRestoreW = ctypes.windll.advpack.RegSaveRestoreW
RegSaveRestoreW.restype = ctypes.c_int
RegSaveRestoreW.argtypes = [
wintypes.HANDLE, # hWnd : HWND
wintypes.LPCWSTR, # pszTitleString : LPCWSTR
wintypes.HANDLE, # hkBckupKey : HKEY
wintypes.LPCWSTR, # pcszRootKey : LPCWSTR
wintypes.LPCWSTR, # pcszSubKey : LPCWSTR
wintypes.LPCWSTR, # pcszValueName : LPCWSTR
wintypes.DWORD, # dwFlags : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ADVPACK.dll')
RegSaveRestoreW = Fiddle::Function.new(
lib['RegSaveRestoreW'],
[
Fiddle::TYPE_VOIDP, # hWnd : HWND
Fiddle::TYPE_VOIDP, # pszTitleString : LPCWSTR
Fiddle::TYPE_VOIDP, # hkBckupKey : HKEY
Fiddle::TYPE_VOIDP, # pcszRootKey : LPCWSTR
Fiddle::TYPE_VOIDP, # pcszSubKey : LPCWSTR
Fiddle::TYPE_VOIDP, # pcszValueName : LPCWSTR
-Fiddle::TYPE_INT, # dwFlags : DWORD
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "advpack")]
extern "system" {
fn RegSaveRestoreW(
hWnd: *mut core::ffi::c_void, // HWND
pszTitleString: *const u16, // LPCWSTR
hkBckupKey: *mut core::ffi::c_void, // HKEY
pcszRootKey: *const u16, // LPCWSTR
pcszSubKey: *const u16, // LPCWSTR
pcszValueName: *const u16, // LPCWSTR
dwFlags: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ADVPACK.dll", CharSet = CharSet.Unicode)]
public static extern int RegSaveRestoreW(IntPtr hWnd, [MarshalAs(UnmanagedType.LPWStr)] string pszTitleString, IntPtr hkBckupKey, [MarshalAs(UnmanagedType.LPWStr)] string pcszRootKey, [MarshalAs(UnmanagedType.LPWStr)] string pcszSubKey, [MarshalAs(UnmanagedType.LPWStr)] string pcszValueName, uint dwFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVPACK_RegSaveRestoreW' -Namespace Win32 -PassThru
# $api::RegSaveRestoreW(hWnd, pszTitleString, hkBckupKey, pcszRootKey, pcszSubKey, pcszValueName, dwFlags)#uselib "ADVPACK.dll"
#func global RegSaveRestoreW "RegSaveRestoreW" wptr, wptr, wptr, wptr, wptr, wptr, wptr
; RegSaveRestoreW hWnd, pszTitleString, hkBckupKey, pcszRootKey, pcszSubKey, pcszValueName, dwFlags ; 戻り値は stat
; hWnd : HWND -> "wptr"
; pszTitleString : LPCWSTR -> "wptr"
; hkBckupKey : HKEY -> "wptr"
; pcszRootKey : LPCWSTR -> "wptr"
; pcszSubKey : LPCWSTR -> "wptr"
; pcszValueName : LPCWSTR -> "wptr"
; dwFlags : DWORD -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "ADVPACK.dll"
#cfunc global RegSaveRestoreW "RegSaveRestoreW" sptr, wstr, sptr, wstr, wstr, wstr, int
; res = RegSaveRestoreW(hWnd, pszTitleString, hkBckupKey, pcszRootKey, pcszSubKey, pcszValueName, dwFlags)
; hWnd : HWND -> "sptr"
; pszTitleString : LPCWSTR -> "wstr"
; hkBckupKey : HKEY -> "sptr"
; pcszRootKey : LPCWSTR -> "wstr"
; pcszSubKey : LPCWSTR -> "wstr"
; pcszValueName : LPCWSTR -> "wstr"
; dwFlags : DWORD -> "int"; HRESULT RegSaveRestoreW(HWND hWnd, LPCWSTR pszTitleString, HKEY hkBckupKey, LPCWSTR pcszRootKey, LPCWSTR pcszSubKey, LPCWSTR pcszValueName, DWORD dwFlags)
#uselib "ADVPACK.dll"
#cfunc global RegSaveRestoreW "RegSaveRestoreW" intptr, wstr, intptr, wstr, wstr, wstr, int
; res = RegSaveRestoreW(hWnd, pszTitleString, hkBckupKey, pcszRootKey, pcszSubKey, pcszValueName, dwFlags)
; hWnd : HWND -> "intptr"
; pszTitleString : LPCWSTR -> "wstr"
; hkBckupKey : HKEY -> "intptr"
; pcszRootKey : LPCWSTR -> "wstr"
; pcszSubKey : LPCWSTR -> "wstr"
; pcszValueName : LPCWSTR -> "wstr"
; dwFlags : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
advpack = windows.NewLazySystemDLL("ADVPACK.dll")
procRegSaveRestoreW = advpack.NewProc("RegSaveRestoreW")
)
// hWnd (HWND), pszTitleString (LPCWSTR), hkBckupKey (HKEY), pcszRootKey (LPCWSTR), pcszSubKey (LPCWSTR), pcszValueName (LPCWSTR), dwFlags (DWORD)
r1, _, err := procRegSaveRestoreW.Call(
uintptr(hWnd),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszTitleString))),
uintptr(hkBckupKey),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pcszRootKey))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pcszSubKey))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pcszValueName))),
uintptr(dwFlags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction RegSaveRestoreW(
hWnd: THandle; // HWND
pszTitleString: PWideChar; // LPCWSTR
hkBckupKey: THandle; // HKEY
pcszRootKey: PWideChar; // LPCWSTR
pcszSubKey: PWideChar; // LPCWSTR
pcszValueName: PWideChar; // LPCWSTR
dwFlags: DWORD // DWORD
): Integer; stdcall;
external 'ADVPACK.dll' name 'RegSaveRestoreW';result := DllCall("ADVPACK\RegSaveRestoreW"
, "Ptr", hWnd ; HWND
, "WStr", pszTitleString ; LPCWSTR
, "Ptr", hkBckupKey ; HKEY
, "WStr", pcszRootKey ; LPCWSTR
, "WStr", pcszSubKey ; LPCWSTR
, "WStr", pcszValueName ; LPCWSTR
, "UInt", dwFlags ; DWORD
, "Int") ; return: HRESULT●RegSaveRestoreW(hWnd, pszTitleString, hkBckupKey, pcszRootKey, pcszSubKey, pcszValueName, dwFlags) = DLL("ADVPACK.dll", "int RegSaveRestoreW(void*, char*, void*, char*, char*, char*, dword)")
# 呼び出し: RegSaveRestoreW(hWnd, pszTitleString, hkBckupKey, pcszRootKey, pcszSubKey, pcszValueName, dwFlags)
# hWnd : HWND -> "void*"
# pszTitleString : LPCWSTR -> "char*"
# hkBckupKey : HKEY -> "void*"
# pcszRootKey : LPCWSTR -> "char*"
# pcszSubKey : LPCWSTR -> "char*"
# pcszValueName : LPCWSTR -> "char*"
# dwFlags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。