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

RmRestart

関数
停止したアプリやサービスを再起動する。
DLLrstrtmgr.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

// rstrtmgr.dll
#include <windows.h>

WIN32_ERROR RmRestart(
    DWORD dwSessionHandle,
    DWORD dwRestartFlags,   // optional
    RM_WRITE_STATUS_CALLBACK fnStatus   // optional
);

パラメーター

名前方向
dwSessionHandleDWORDin
dwRestartFlagsDWORDoptional
fnStatusRM_WRITE_STATUS_CALLBACKinoptional

戻り値の型: WIN32_ERROR

各言語での呼び出し定義

// rstrtmgr.dll
#include <windows.h>

WIN32_ERROR RmRestart(
    DWORD dwSessionHandle,
    DWORD dwRestartFlags,   // optional
    RM_WRITE_STATUS_CALLBACK fnStatus   // optional
);
[DllImport("rstrtmgr.dll", ExactSpelling = true)]
static extern uint RmRestart(
    uint dwSessionHandle,   // DWORD
    uint dwRestartFlags,   // DWORD optional
    IntPtr fnStatus   // RM_WRITE_STATUS_CALLBACK optional
);
<DllImport("rstrtmgr.dll", ExactSpelling:=True)>
Public Shared Function RmRestart(
    dwSessionHandle As UInteger,   ' DWORD
    dwRestartFlags As UInteger,   ' DWORD optional
    fnStatus As IntPtr   ' RM_WRITE_STATUS_CALLBACK optional
) As UInteger
End Function
' dwSessionHandle : DWORD
' dwRestartFlags : DWORD optional
' fnStatus : RM_WRITE_STATUS_CALLBACK optional
Declare PtrSafe Function RmRestart Lib "rstrtmgr" ( _
    ByVal dwSessionHandle As Long, _
    ByVal dwRestartFlags As Long, _
    ByVal fnStatus As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

RmRestart = ctypes.windll.rstrtmgr.RmRestart
RmRestart.restype = wintypes.DWORD
RmRestart.argtypes = [
    wintypes.DWORD,  # dwSessionHandle : DWORD
    wintypes.DWORD,  # dwRestartFlags : DWORD optional
    ctypes.c_void_p,  # fnStatus : RM_WRITE_STATUS_CALLBACK optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('rstrtmgr.dll')
RmRestart = Fiddle::Function.new(
  lib['RmRestart'],
  [
    -Fiddle::TYPE_INT,  # dwSessionHandle : DWORD
    -Fiddle::TYPE_INT,  # dwRestartFlags : DWORD optional
    Fiddle::TYPE_VOIDP,  # fnStatus : RM_WRITE_STATUS_CALLBACK optional
  ],
  -Fiddle::TYPE_INT)
#[link(name = "rstrtmgr")]
extern "system" {
    fn RmRestart(
        dwSessionHandle: u32,  // DWORD
        dwRestartFlags: u32,  // DWORD optional
        fnStatus: *const core::ffi::c_void  // RM_WRITE_STATUS_CALLBACK optional
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("rstrtmgr.dll")]
public static extern uint RmRestart(uint dwSessionHandle, uint dwRestartFlags, IntPtr fnStatus);
"@
$api = Add-Type -MemberDefinition $sig -Name 'rstrtmgr_RmRestart' -Namespace Win32 -PassThru
# $api::RmRestart(dwSessionHandle, dwRestartFlags, fnStatus)
#uselib "rstrtmgr.dll"
#func global RmRestart "RmRestart" sptr, sptr, sptr
; RmRestart dwSessionHandle, dwRestartFlags, fnStatus   ; 戻り値は stat
; dwSessionHandle : DWORD -> "sptr"
; dwRestartFlags : DWORD optional -> "sptr"
; fnStatus : RM_WRITE_STATUS_CALLBACK optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "rstrtmgr.dll"
#cfunc global RmRestart "RmRestart" int, int, sptr
; res = RmRestart(dwSessionHandle, dwRestartFlags, fnStatus)
; dwSessionHandle : DWORD -> "int"
; dwRestartFlags : DWORD optional -> "int"
; fnStatus : RM_WRITE_STATUS_CALLBACK optional -> "sptr"
; WIN32_ERROR RmRestart(DWORD dwSessionHandle, DWORD dwRestartFlags, RM_WRITE_STATUS_CALLBACK fnStatus)
#uselib "rstrtmgr.dll"
#cfunc global RmRestart "RmRestart" int, int, intptr
; res = RmRestart(dwSessionHandle, dwRestartFlags, fnStatus)
; dwSessionHandle : DWORD -> "int"
; dwRestartFlags : DWORD optional -> "int"
; fnStatus : RM_WRITE_STATUS_CALLBACK optional -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	rstrtmgr = windows.NewLazySystemDLL("rstrtmgr.dll")
	procRmRestart = rstrtmgr.NewProc("RmRestart")
)

// dwSessionHandle (DWORD), dwRestartFlags (DWORD optional), fnStatus (RM_WRITE_STATUS_CALLBACK optional)
r1, _, err := procRmRestart.Call(
	uintptr(dwSessionHandle),
	uintptr(dwRestartFlags),
	uintptr(fnStatus),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // WIN32_ERROR
function RmRestart(
  dwSessionHandle: DWORD;   // DWORD
  dwRestartFlags: DWORD;   // DWORD optional
  fnStatus: Pointer   // RM_WRITE_STATUS_CALLBACK optional
): DWORD; stdcall;
  external 'rstrtmgr.dll' name 'RmRestart';
result := DllCall("rstrtmgr\RmRestart"
    , "UInt", dwSessionHandle   ; DWORD
    , "UInt", dwRestartFlags   ; DWORD optional
    , "Ptr", fnStatus   ; RM_WRITE_STATUS_CALLBACK optional
    , "UInt")   ; return: WIN32_ERROR
●RmRestart(dwSessionHandle, dwRestartFlags, fnStatus) = DLL("rstrtmgr.dll", "dword RmRestart(dword, dword, void*)")
# 呼び出し: RmRestart(dwSessionHandle, dwRestartFlags, fnStatus)
# dwSessionHandle : DWORD -> "dword"
# dwRestartFlags : DWORD optional -> "dword"
# fnStatus : RM_WRITE_STATUS_CALLBACK optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。