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