ホーム › System.RestartManager › RmJoinSession
RmJoinSession
関数既存の再起動マネージャーセッションに参加する。
シグネチャ
// rstrtmgr.dll
#include <windows.h>
WIN32_ERROR RmJoinSession(
DWORD* pSessionHandle,
LPCWSTR strSessionKey
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pSessionHandle | DWORD* | out | 参加したセッションのハンドルを受け取る変数へのポインター。 |
| strSessionKey | LPCWSTR | in | 参加対象のセッションを識別するセッションキー文字列。 |
戻り値の型: 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 方式にも切替可。#uselib "rstrtmgr.dll" #cfunc global RmJoinSession "RmJoinSession" sptr, wstr ; res = RmJoinSession(varptr(pSessionHandle), strSessionKey) ; pSessionHandle : DWORD* out -> "sptr" ; strSessionKey : LPCWSTR -> "wstr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは 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 方式にも切替可。; WIN32_ERROR RmJoinSession(DWORD* pSessionHandle, LPCWSTR strSessionKey) #uselib "rstrtmgr.dll" #cfunc global RmJoinSession "RmJoinSession" intptr, wstr ; res = RmJoinSession(varptr(pSessionHandle), strSessionKey) ; pSessionHandle : DWORD* out -> "intptr" ; strSessionKey : LPCWSTR -> "wstr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは 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_ERRORfunction 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)。const std = @import("std");
extern "rstrtmgr" fn RmJoinSession(
pSessionHandle: [*c]u32, // DWORD* out
strSessionKey: [*c]const u16 // LPCWSTR
) callconv(std.os.windows.WINAPI) u32;proc RmJoinSession(
pSessionHandle: ptr uint32, # DWORD* out
strSessionKey: WideCString # LPCWSTR
): uint32 {.importc: "RmJoinSession", stdcall, dynlib: "rstrtmgr.dll".}pragma(lib, "rstrtmgr");
extern(Windows)
uint RmJoinSession(
uint* pSessionHandle, // DWORD* out
const(wchar)* strSessionKey // LPCWSTR
);ccall((:RmJoinSession, "rstrtmgr.dll"), stdcall, UInt32,
(Ptr{UInt32}, Cwstring),
pSessionHandle, strSessionKey)
# pSessionHandle : DWORD* out -> Ptr{UInt32}
# strSessionKey : LPCWSTR -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t RmJoinSession(
uint32_t* pSessionHandle,
const uint16_t* strSessionKey);
]]
local rstrtmgr = ffi.load("rstrtmgr")
-- rstrtmgr.RmJoinSession(pSessionHandle, strSessionKey)
-- pSessionHandle : DWORD* out
-- strSessionKey : LPCWSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('rstrtmgr.dll');
const RmJoinSession = lib.func('__stdcall', 'RmJoinSession', 'uint32_t', ['uint32_t *', 'str16']);
// RmJoinSession(pSessionHandle, strSessionKey)
// pSessionHandle : DWORD* out -> 'uint32_t *'
// strSessionKey : LPCWSTR -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("rstrtmgr.dll", {
RmJoinSession: { parameters: ["pointer", "buffer"], result: "u32" },
});
// lib.symbols.RmJoinSession(pSessionHandle, strSessionKey)
// pSessionHandle : DWORD* out -> "pointer"
// strSessionKey : LPCWSTR -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t RmJoinSession(
uint32_t* pSessionHandle,
const uint16_t* strSessionKey);
C, "rstrtmgr.dll");
// $ffi->RmJoinSession(pSessionHandle, strSessionKey);
// pSessionHandle : DWORD* out
// strSessionKey : LPCWSTR
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Rstrtmgr extends StdCallLibrary {
Rstrtmgr INSTANCE = Native.load("rstrtmgr", Rstrtmgr.class);
int RmJoinSession(
IntByReference pSessionHandle, // DWORD* out
WString strSessionKey // LPCWSTR
);
}@[Link("rstrtmgr")]
lib Librstrtmgr
fun RmJoinSession = RmJoinSession(
pSessionHandle : UInt32*, # DWORD* out
strSessionKey : UInt16* # LPCWSTR
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef RmJoinSessionNative = Uint32 Function(Pointer<Uint32>, Pointer<Utf16>);
typedef RmJoinSessionDart = int Function(Pointer<Uint32>, Pointer<Utf16>);
final RmJoinSession = DynamicLibrary.open('rstrtmgr.dll')
.lookupFunction<RmJoinSessionNative, RmJoinSessionDart>('RmJoinSession');
// pSessionHandle : DWORD* out -> Pointer<Uint32>
// strSessionKey : LPCWSTR -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function RmJoinSession(
pSessionHandle: Pointer; // DWORD* out
strSessionKey: PWideChar // LPCWSTR
): DWORD; stdcall;
external 'rstrtmgr.dll' name 'RmJoinSession';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "RmJoinSession"
c_RmJoinSession :: Ptr Word32 -> CWString -> IO Word32
-- pSessionHandle : DWORD* out -> Ptr Word32
-- strSessionKey : LPCWSTR -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let rmjoinsession =
foreign "RmJoinSession"
((ptr uint32_t) @-> (ptr uint16_t) @-> returning uint32_t)
(* pSessionHandle : DWORD* out -> (ptr uint32_t) *)
(* strSessionKey : LPCWSTR -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library rstrtmgr (t "rstrtmgr.dll"))
(cffi:use-foreign-library rstrtmgr)
(cffi:defcfun ("RmJoinSession" rm-join-session :convention :stdcall) :uint32
(p-session-handle :pointer) ; DWORD* out
(str-session-key (:string :encoding :utf-16le))) ; LPCWSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $RmJoinSession = Win32::API::More->new('rstrtmgr',
'DWORD RmJoinSession(LPVOID pSessionHandle, LPCWSTR strSessionKey)');
# my $ret = $RmJoinSession->Call($pSessionHandle, $strSessionKey);
# pSessionHandle : DWORD* out -> LPVOID
# strSessionKey : LPCWSTR -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型