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

RmRegisterResources

関数
ファイル・プロセス・サービスをセッションに登録する。
DLLrstrtmgr.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

WIN32_ERROR RmRegisterResources(
    DWORD dwSessionHandle,
    DWORD nFiles,
    LPCWSTR* rgsFileNames,   // optional
    DWORD nApplications,
    RM_UNIQUE_PROCESS* rgApplications,   // optional
    DWORD nServices,
    LPCWSTR* rgsServiceNames   // optional
);

パラメーター

名前方向
dwSessionHandleDWORDin
nFilesDWORDin
rgsFileNamesLPCWSTR*inoptional
nApplicationsDWORDin
rgApplicationsRM_UNIQUE_PROCESS*inoptional
nServicesDWORDin
rgsServiceNamesLPCWSTR*inoptional

戻り値の型: WIN32_ERROR

各言語での呼び出し定義

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

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

RmRegisterResources = ctypes.windll.rstrtmgr.RmRegisterResources
RmRegisterResources.restype = wintypes.DWORD
RmRegisterResources.argtypes = [
    wintypes.DWORD,  # dwSessionHandle : DWORD
    wintypes.DWORD,  # nFiles : DWORD
    ctypes.c_void_p,  # rgsFileNames : LPCWSTR* optional
    wintypes.DWORD,  # nApplications : DWORD
    ctypes.c_void_p,  # rgApplications : RM_UNIQUE_PROCESS* optional
    wintypes.DWORD,  # nServices : DWORD
    ctypes.c_void_p,  # rgsServiceNames : LPCWSTR* optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('rstrtmgr.dll')
RmRegisterResources = Fiddle::Function.new(
  lib['RmRegisterResources'],
  [
    -Fiddle::TYPE_INT,  # dwSessionHandle : DWORD
    -Fiddle::TYPE_INT,  # nFiles : DWORD
    Fiddle::TYPE_VOIDP,  # rgsFileNames : LPCWSTR* optional
    -Fiddle::TYPE_INT,  # nApplications : DWORD
    Fiddle::TYPE_VOIDP,  # rgApplications : RM_UNIQUE_PROCESS* optional
    -Fiddle::TYPE_INT,  # nServices : DWORD
    Fiddle::TYPE_VOIDP,  # rgsServiceNames : LPCWSTR* optional
  ],
  -Fiddle::TYPE_INT)
#[link(name = "rstrtmgr")]
extern "system" {
    fn RmRegisterResources(
        dwSessionHandle: u32,  // DWORD
        nFiles: u32,  // DWORD
        rgsFileNames: *const *const u16,  // LPCWSTR* optional
        nApplications: u32,  // DWORD
        rgApplications: *mut RM_UNIQUE_PROCESS,  // RM_UNIQUE_PROCESS* optional
        nServices: u32,  // DWORD
        rgsServiceNames: *const *const u16  // LPCWSTR* optional
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("rstrtmgr.dll")]
public static extern uint RmRegisterResources(uint dwSessionHandle, uint nFiles, IntPtr rgsFileNames, uint nApplications, IntPtr rgApplications, uint nServices, IntPtr rgsServiceNames);
"@
$api = Add-Type -MemberDefinition $sig -Name 'rstrtmgr_RmRegisterResources' -Namespace Win32 -PassThru
# $api::RmRegisterResources(dwSessionHandle, nFiles, rgsFileNames, nApplications, rgApplications, nServices, rgsServiceNames)
#uselib "rstrtmgr.dll"
#func global RmRegisterResources "RmRegisterResources" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; RmRegisterResources dwSessionHandle, nFiles, varptr(rgsFileNames), nApplications, varptr(rgApplications), nServices, varptr(rgsServiceNames)   ; 戻り値は stat
; dwSessionHandle : DWORD -> "sptr"
; nFiles : DWORD -> "sptr"
; rgsFileNames : LPCWSTR* optional -> "sptr"
; nApplications : DWORD -> "sptr"
; rgApplications : RM_UNIQUE_PROCESS* optional -> "sptr"
; nServices : DWORD -> "sptr"
; rgsServiceNames : LPCWSTR* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "rstrtmgr.dll"
#cfunc global RmRegisterResources "RmRegisterResources" int, int, var, int, var, int, var
; res = RmRegisterResources(dwSessionHandle, nFiles, rgsFileNames, nApplications, rgApplications, nServices, rgsServiceNames)
; dwSessionHandle : DWORD -> "int"
; nFiles : DWORD -> "int"
; rgsFileNames : LPCWSTR* optional -> "var"
; nApplications : DWORD -> "int"
; rgApplications : RM_UNIQUE_PROCESS* optional -> "var"
; nServices : DWORD -> "int"
; rgsServiceNames : LPCWSTR* optional -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; WIN32_ERROR RmRegisterResources(DWORD dwSessionHandle, DWORD nFiles, LPCWSTR* rgsFileNames, DWORD nApplications, RM_UNIQUE_PROCESS* rgApplications, DWORD nServices, LPCWSTR* rgsServiceNames)
#uselib "rstrtmgr.dll"
#cfunc global RmRegisterResources "RmRegisterResources" int, int, var, int, var, int, var
; res = RmRegisterResources(dwSessionHandle, nFiles, rgsFileNames, nApplications, rgApplications, nServices, rgsServiceNames)
; dwSessionHandle : DWORD -> "int"
; nFiles : DWORD -> "int"
; rgsFileNames : LPCWSTR* optional -> "var"
; nApplications : DWORD -> "int"
; rgApplications : RM_UNIQUE_PROCESS* optional -> "var"
; nServices : DWORD -> "int"
; rgsServiceNames : LPCWSTR* optional -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	rstrtmgr = windows.NewLazySystemDLL("rstrtmgr.dll")
	procRmRegisterResources = rstrtmgr.NewProc("RmRegisterResources")
)

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