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

SRSetRestorePointA

関数
システムの復元ポイントを作成する(ANSI版)。
DLLsfc.dll文字セットANSI (-A)呼出規約winapi対応OSWindows XP 以降

シグネチャ

// sfc.dll  (ANSI / -A)
#include <windows.h>

BOOL SRSetRestorePointA(
    RESTOREPOINTINFOA* pRestorePtSpec,
    STATEMGRSTATUS* pSMgrStatus
);

パラメーター

名前方向
pRestorePtSpecRESTOREPOINTINFOA*in
pSMgrStatusSTATEMGRSTATUS*out

戻り値の型: BOOL

各言語での呼び出し定義

// sfc.dll  (ANSI / -A)
#include <windows.h>

BOOL SRSetRestorePointA(
    RESTOREPOINTINFOA* pRestorePtSpec,
    STATEMGRSTATUS* pSMgrStatus
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("sfc.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern bool SRSetRestorePointA(
    IntPtr pRestorePtSpec,   // RESTOREPOINTINFOA*
    IntPtr pSMgrStatus   // STATEMGRSTATUS* out
);
<DllImport("sfc.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function SRSetRestorePointA(
    pRestorePtSpec As IntPtr,   ' RESTOREPOINTINFOA*
    pSMgrStatus As IntPtr   ' STATEMGRSTATUS* out
) As Boolean
End Function
' pRestorePtSpec : RESTOREPOINTINFOA*
' pSMgrStatus : STATEMGRSTATUS* out
Declare PtrSafe Function SRSetRestorePointA Lib "sfc" ( _
    ByVal pRestorePtSpec As LongPtr, _
    ByVal pSMgrStatus As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SRSetRestorePointA = ctypes.windll.sfc.SRSetRestorePointA
SRSetRestorePointA.restype = wintypes.BOOL
SRSetRestorePointA.argtypes = [
    ctypes.c_void_p,  # pRestorePtSpec : RESTOREPOINTINFOA*
    ctypes.c_void_p,  # pSMgrStatus : STATEMGRSTATUS* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('sfc.dll')
SRSetRestorePointA = Fiddle::Function.new(
  lib['SRSetRestorePointA'],
  [
    Fiddle::TYPE_VOIDP,  # pRestorePtSpec : RESTOREPOINTINFOA*
    Fiddle::TYPE_VOIDP,  # pSMgrStatus : STATEMGRSTATUS* out
  ],
  Fiddle::TYPE_INT)
#[link(name = "sfc")]
extern "system" {
    fn SRSetRestorePointA(
        pRestorePtSpec: *mut RESTOREPOINTINFOA,  // RESTOREPOINTINFOA*
        pSMgrStatus: *mut STATEMGRSTATUS  // STATEMGRSTATUS* out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("sfc.dll", CharSet = CharSet.Ansi)]
public static extern bool SRSetRestorePointA(IntPtr pRestorePtSpec, IntPtr pSMgrStatus);
"@
$api = Add-Type -MemberDefinition $sig -Name 'sfc_SRSetRestorePointA' -Namespace Win32 -PassThru
# $api::SRSetRestorePointA(pRestorePtSpec, pSMgrStatus)
#uselib "sfc.dll"
#func global SRSetRestorePointA "SRSetRestorePointA" sptr, sptr
; SRSetRestorePointA varptr(pRestorePtSpec), varptr(pSMgrStatus)   ; 戻り値は stat
; pRestorePtSpec : RESTOREPOINTINFOA* -> "sptr"
; pSMgrStatus : STATEMGRSTATUS* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "sfc.dll"
#cfunc global SRSetRestorePointA "SRSetRestorePointA" var, var
; res = SRSetRestorePointA(pRestorePtSpec, pSMgrStatus)
; pRestorePtSpec : RESTOREPOINTINFOA* -> "var"
; pSMgrStatus : STATEMGRSTATUS* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL SRSetRestorePointA(RESTOREPOINTINFOA* pRestorePtSpec, STATEMGRSTATUS* pSMgrStatus)
#uselib "sfc.dll"
#cfunc global SRSetRestorePointA "SRSetRestorePointA" var, var
; res = SRSetRestorePointA(pRestorePtSpec, pSMgrStatus)
; pRestorePtSpec : RESTOREPOINTINFOA* -> "var"
; pSMgrStatus : STATEMGRSTATUS* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	sfc = windows.NewLazySystemDLL("sfc.dll")
	procSRSetRestorePointA = sfc.NewProc("SRSetRestorePointA")
)

// pRestorePtSpec (RESTOREPOINTINFOA*), pSMgrStatus (STATEMGRSTATUS* out)
r1, _, err := procSRSetRestorePointA.Call(
	uintptr(pRestorePtSpec),
	uintptr(pSMgrStatus),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function SRSetRestorePointA(
  pRestorePtSpec: Pointer;   // RESTOREPOINTINFOA*
  pSMgrStatus: Pointer   // STATEMGRSTATUS* out
): BOOL; stdcall;
  external 'sfc.dll' name 'SRSetRestorePointA';
result := DllCall("sfc\SRSetRestorePointA"
    , "Ptr", pRestorePtSpec   ; RESTOREPOINTINFOA*
    , "Ptr", pSMgrStatus   ; STATEMGRSTATUS* out
    , "Int")   ; return: BOOL
●SRSetRestorePointA(pRestorePtSpec, pSMgrStatus) = DLL("sfc.dll", "bool SRSetRestorePointA(void*, void*)")
# 呼び出し: SRSetRestorePointA(pRestorePtSpec, pSMgrStatus)
# pRestorePtSpec : RESTOREPOINTINFOA* -> "void*"
# pSMgrStatus : STATEMGRSTATUS* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。