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