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

RmJoinSession

関数
既存の再起動マネージャーセッションに参加する。
DLLRstrtMgr.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

WIN32_ERROR RmJoinSession(
    DWORD* pSessionHandle,
    LPCWSTR strSessionKey
);

パラメーター

名前方向
pSessionHandleDWORD*out
strSessionKeyLPCWSTRin

戻り値の型: WIN32_ERROR

各言語での呼び出し定義

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

WIN32_ERROR RmJoinSession(
    DWORD* pSessionHandle,
    LPCWSTR strSessionKey
);
[DllImport("RstrtMgr.dll", ExactSpelling = true)]
static extern uint RmJoinSession(
    out uint pSessionHandle,   // DWORD* out
    [MarshalAs(UnmanagedType.LPWStr)] string strSessionKey   // LPCWSTR
);
<DllImport("RstrtMgr.dll", ExactSpelling:=True)>
Public Shared Function RmJoinSession(
    <Out> ByRef pSessionHandle As UInteger,   ' DWORD* out
    <MarshalAs(UnmanagedType.LPWStr)> strSessionKey As String   ' LPCWSTR
) As UInteger
End Function
' pSessionHandle : DWORD* out
' strSessionKey : LPCWSTR
Declare PtrSafe Function RmJoinSession Lib "rstrtmgr" ( _
    ByRef pSessionHandle As Long, _
    ByVal strSessionKey As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

RmJoinSession = ctypes.windll.rstrtmgr.RmJoinSession
RmJoinSession.restype = wintypes.DWORD
RmJoinSession.argtypes = [
    ctypes.POINTER(wintypes.DWORD),  # pSessionHandle : DWORD* out
    wintypes.LPCWSTR,  # strSessionKey : LPCWSTR
]
require 'fiddle'
require 'fiddle/import'

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

var (
	rstrtmgr = windows.NewLazySystemDLL("RstrtMgr.dll")
	procRmJoinSession = rstrtmgr.NewProc("RmJoinSession")
)

// pSessionHandle (DWORD* out), strSessionKey (LPCWSTR)
r1, _, err := procRmJoinSession.Call(
	uintptr(pSessionHandle),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(strSessionKey))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // WIN32_ERROR
function RmJoinSession(
  pSessionHandle: Pointer;   // DWORD* out
  strSessionKey: PWideChar   // LPCWSTR
): DWORD; stdcall;
  external 'RstrtMgr.dll' name 'RmJoinSession';
result := DllCall("RstrtMgr\RmJoinSession"
    , "Ptr", pSessionHandle   ; DWORD* out
    , "WStr", strSessionKey   ; LPCWSTR
    , "UInt")   ; return: WIN32_ERROR
●RmJoinSession(pSessionHandle, strSessionKey) = DLL("RstrtMgr.dll", "dword RmJoinSession(void*, char*)")
# 呼び出し: RmJoinSession(pSessionHandle, strSessionKey)
# pSessionHandle : DWORD* out -> "void*"
# strSessionKey : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。