ホーム › System.Recovery › RegisterApplicationRecoveryCallback
RegisterApplicationRecoveryCallback
関数アプリ障害時の回復用コールバック関数を登録する。
シグネチャ
// KERNEL32.dll
#include <windows.h>
HRESULT RegisterApplicationRecoveryCallback(
APPLICATION_RECOVERY_CALLBACK pRecoveyCallback,
void* pvParameter, // optional
DWORD dwPingInterval,
DWORD dwFlags
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pRecoveyCallback | APPLICATION_RECOVERY_CALLBACK | in |
| pvParameter | void* | inoptional |
| dwPingInterval | DWORD | in |
| dwFlags | DWORD | in |
戻り値の型: HRESULT
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
HRESULT RegisterApplicationRecoveryCallback(
APPLICATION_RECOVERY_CALLBACK pRecoveyCallback,
void* pvParameter, // optional
DWORD dwPingInterval,
DWORD dwFlags
);[DllImport("KERNEL32.dll", ExactSpelling = true)]
static extern int RegisterApplicationRecoveryCallback(
IntPtr pRecoveyCallback, // APPLICATION_RECOVERY_CALLBACK
IntPtr pvParameter, // void* optional
uint dwPingInterval, // DWORD
uint dwFlags // DWORD
);<DllImport("KERNEL32.dll", ExactSpelling:=True)>
Public Shared Function RegisterApplicationRecoveryCallback(
pRecoveyCallback As IntPtr, ' APPLICATION_RECOVERY_CALLBACK
pvParameter As IntPtr, ' void* optional
dwPingInterval As UInteger, ' DWORD
dwFlags As UInteger ' DWORD
) As Integer
End Function' pRecoveyCallback : APPLICATION_RECOVERY_CALLBACK
' pvParameter : void* optional
' dwPingInterval : DWORD
' dwFlags : DWORD
Declare PtrSafe Function RegisterApplicationRecoveryCallback Lib "kernel32" ( _
ByVal pRecoveyCallback As LongPtr, _
ByVal pvParameter As LongPtr, _
ByVal dwPingInterval As Long, _
ByVal dwFlags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
RegisterApplicationRecoveryCallback = ctypes.windll.kernel32.RegisterApplicationRecoveryCallback
RegisterApplicationRecoveryCallback.restype = ctypes.c_int
RegisterApplicationRecoveryCallback.argtypes = [
ctypes.c_void_p, # pRecoveyCallback : APPLICATION_RECOVERY_CALLBACK
ctypes.POINTER(None), # pvParameter : void* optional
wintypes.DWORD, # dwPingInterval : DWORD
wintypes.DWORD, # dwFlags : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
RegisterApplicationRecoveryCallback = Fiddle::Function.new(
lib['RegisterApplicationRecoveryCallback'],
[
Fiddle::TYPE_VOIDP, # pRecoveyCallback : APPLICATION_RECOVERY_CALLBACK
Fiddle::TYPE_VOIDP, # pvParameter : void* optional
-Fiddle::TYPE_INT, # dwPingInterval : DWORD
-Fiddle::TYPE_INT, # dwFlags : DWORD
],
Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn RegisterApplicationRecoveryCallback(
pRecoveyCallback: *const core::ffi::c_void, // APPLICATION_RECOVERY_CALLBACK
pvParameter: *mut (), // void* optional
dwPingInterval: u32, // DWORD
dwFlags: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("KERNEL32.dll")]
public static extern int RegisterApplicationRecoveryCallback(IntPtr pRecoveyCallback, IntPtr pvParameter, uint dwPingInterval, uint dwFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_RegisterApplicationRecoveryCallback' -Namespace Win32 -PassThru
# $api::RegisterApplicationRecoveryCallback(pRecoveyCallback, pvParameter, dwPingInterval, dwFlags)#uselib "KERNEL32.dll"
#func global RegisterApplicationRecoveryCallback "RegisterApplicationRecoveryCallback" sptr, sptr, sptr, sptr
; RegisterApplicationRecoveryCallback pRecoveyCallback, pvParameter, dwPingInterval, dwFlags ; 戻り値は stat
; pRecoveyCallback : APPLICATION_RECOVERY_CALLBACK -> "sptr"
; pvParameter : void* optional -> "sptr"
; dwPingInterval : DWORD -> "sptr"
; dwFlags : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "KERNEL32.dll"
#cfunc global RegisterApplicationRecoveryCallback "RegisterApplicationRecoveryCallback" sptr, sptr, int, int
; res = RegisterApplicationRecoveryCallback(pRecoveyCallback, pvParameter, dwPingInterval, dwFlags)
; pRecoveyCallback : APPLICATION_RECOVERY_CALLBACK -> "sptr"
; pvParameter : void* optional -> "sptr"
; dwPingInterval : DWORD -> "int"
; dwFlags : DWORD -> "int"; HRESULT RegisterApplicationRecoveryCallback(APPLICATION_RECOVERY_CALLBACK pRecoveyCallback, void* pvParameter, DWORD dwPingInterval, DWORD dwFlags)
#uselib "KERNEL32.dll"
#cfunc global RegisterApplicationRecoveryCallback "RegisterApplicationRecoveryCallback" intptr, intptr, int, int
; res = RegisterApplicationRecoveryCallback(pRecoveyCallback, pvParameter, dwPingInterval, dwFlags)
; pRecoveyCallback : APPLICATION_RECOVERY_CALLBACK -> "intptr"
; pvParameter : void* optional -> "intptr"
; dwPingInterval : DWORD -> "int"
; dwFlags : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procRegisterApplicationRecoveryCallback = kernel32.NewProc("RegisterApplicationRecoveryCallback")
)
// pRecoveyCallback (APPLICATION_RECOVERY_CALLBACK), pvParameter (void* optional), dwPingInterval (DWORD), dwFlags (DWORD)
r1, _, err := procRegisterApplicationRecoveryCallback.Call(
uintptr(pRecoveyCallback),
uintptr(pvParameter),
uintptr(dwPingInterval),
uintptr(dwFlags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction RegisterApplicationRecoveryCallback(
pRecoveyCallback: Pointer; // APPLICATION_RECOVERY_CALLBACK
pvParameter: Pointer; // void* optional
dwPingInterval: DWORD; // DWORD
dwFlags: DWORD // DWORD
): Integer; stdcall;
external 'KERNEL32.dll' name 'RegisterApplicationRecoveryCallback';result := DllCall("KERNEL32\RegisterApplicationRecoveryCallback"
, "Ptr", pRecoveyCallback ; APPLICATION_RECOVERY_CALLBACK
, "Ptr", pvParameter ; void* optional
, "UInt", dwPingInterval ; DWORD
, "UInt", dwFlags ; DWORD
, "Int") ; return: HRESULT●RegisterApplicationRecoveryCallback(pRecoveyCallback, pvParameter, dwPingInterval, dwFlags) = DLL("KERNEL32.dll", "int RegisterApplicationRecoveryCallback(void*, void*, dword, dword)")
# 呼び出し: RegisterApplicationRecoveryCallback(pRecoveyCallback, pvParameter, dwPingInterval, dwFlags)
# pRecoveyCallback : APPLICATION_RECOVERY_CALLBACK -> "void*"
# pvParameter : void* optional -> "void*"
# dwPingInterval : DWORD -> "dword"
# dwFlags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。