ホーム › System.RemoteManagement › WSManSetSessionOption
WSManSetSessionOption
関数WS-Manセッションのオプション値を設定する。
シグネチャ
// WsmSvc.dll
#include <windows.h>
DWORD WSManSetSessionOption(
WSMAN_SESSION_HANDLE session,
WSManSessionOption option,
WSMAN_DATA* data
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| session | WSMAN_SESSION_HANDLE | in | オプションを設定する対象のセッションハンドル。 |
| option | WSManSessionOption | in | 設定するセッションオプションを示す WSManSessionOption 列挙値。 |
| data | WSMAN_DATA* | in | オプションに設定する値を格納した WSMAN_DATA 構造体へのポインター。 |
戻り値の型: DWORD
各言語での呼び出し定義
// WsmSvc.dll
#include <windows.h>
DWORD WSManSetSessionOption(
WSMAN_SESSION_HANDLE session,
WSManSessionOption option,
WSMAN_DATA* data
);[DllImport("WsmSvc.dll", ExactSpelling = true)]
static extern uint WSManSetSessionOption(
IntPtr session, // WSMAN_SESSION_HANDLE
int option, // WSManSessionOption
IntPtr data // WSMAN_DATA*
);<DllImport("WsmSvc.dll", ExactSpelling:=True)>
Public Shared Function WSManSetSessionOption(
session As IntPtr, ' WSMAN_SESSION_HANDLE
[option] As Integer, ' WSManSessionOption
data As IntPtr ' WSMAN_DATA*
) As UInteger
End Function' session : WSMAN_SESSION_HANDLE
' option : WSManSessionOption
' data : WSMAN_DATA*
Declare PtrSafe Function WSManSetSessionOption Lib "wsmsvc" ( _
ByVal session As LongPtr, _
ByVal option As Long, _
ByVal data As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
WSManSetSessionOption = ctypes.windll.wsmsvc.WSManSetSessionOption
WSManSetSessionOption.restype = wintypes.DWORD
WSManSetSessionOption.argtypes = [
ctypes.c_ssize_t, # session : WSMAN_SESSION_HANDLE
ctypes.c_int, # option : WSManSessionOption
ctypes.c_void_p, # data : WSMAN_DATA*
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WsmSvc.dll')
WSManSetSessionOption = Fiddle::Function.new(
lib['WSManSetSessionOption'],
[
Fiddle::TYPE_INTPTR_T, # session : WSMAN_SESSION_HANDLE
Fiddle::TYPE_INT, # option : WSManSessionOption
Fiddle::TYPE_VOIDP, # data : WSMAN_DATA*
],
-Fiddle::TYPE_INT)#[link(name = "wsmsvc")]
extern "system" {
fn WSManSetSessionOption(
session: isize, // WSMAN_SESSION_HANDLE
option: i32, // WSManSessionOption
data: *mut WSMAN_DATA // WSMAN_DATA*
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("WsmSvc.dll")]
public static extern uint WSManSetSessionOption(IntPtr session, int option, IntPtr data);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WsmSvc_WSManSetSessionOption' -Namespace Win32 -PassThru
# $api::WSManSetSessionOption(session, option, data)#uselib "WsmSvc.dll"
#func global WSManSetSessionOption "WSManSetSessionOption" sptr, sptr, sptr
; WSManSetSessionOption session, option, varptr(data) ; 戻り値は stat
; session : WSMAN_SESSION_HANDLE -> "sptr"
; option : WSManSessionOption -> "sptr"
; data : WSMAN_DATA* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "WsmSvc.dll" #cfunc global WSManSetSessionOption "WSManSetSessionOption" sptr, int, var ; res = WSManSetSessionOption(session, option, data) ; session : WSMAN_SESSION_HANDLE -> "sptr" ; option : WSManSessionOption -> "int" ; data : WSMAN_DATA* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "WsmSvc.dll" #cfunc global WSManSetSessionOption "WSManSetSessionOption" sptr, int, sptr ; res = WSManSetSessionOption(session, option, varptr(data)) ; session : WSMAN_SESSION_HANDLE -> "sptr" ; option : WSManSessionOption -> "int" ; data : WSMAN_DATA* -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD WSManSetSessionOption(WSMAN_SESSION_HANDLE session, WSManSessionOption option, WSMAN_DATA* data) #uselib "WsmSvc.dll" #cfunc global WSManSetSessionOption "WSManSetSessionOption" intptr, int, var ; res = WSManSetSessionOption(session, option, data) ; session : WSMAN_SESSION_HANDLE -> "intptr" ; option : WSManSessionOption -> "int" ; data : WSMAN_DATA* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD WSManSetSessionOption(WSMAN_SESSION_HANDLE session, WSManSessionOption option, WSMAN_DATA* data) #uselib "WsmSvc.dll" #cfunc global WSManSetSessionOption "WSManSetSessionOption" intptr, int, intptr ; res = WSManSetSessionOption(session, option, varptr(data)) ; session : WSMAN_SESSION_HANDLE -> "intptr" ; option : WSManSessionOption -> "int" ; data : WSMAN_DATA* -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wsmsvc = windows.NewLazySystemDLL("WsmSvc.dll")
procWSManSetSessionOption = wsmsvc.NewProc("WSManSetSessionOption")
)
// session (WSMAN_SESSION_HANDLE), option (WSManSessionOption), data (WSMAN_DATA*)
r1, _, err := procWSManSetSessionOption.Call(
uintptr(session),
uintptr(option),
uintptr(data),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction WSManSetSessionOption(
session: NativeInt; // WSMAN_SESSION_HANDLE
option: Integer; // WSManSessionOption
data: Pointer // WSMAN_DATA*
): DWORD; stdcall;
external 'WsmSvc.dll' name 'WSManSetSessionOption';result := DllCall("WsmSvc\WSManSetSessionOption"
, "Ptr", session ; WSMAN_SESSION_HANDLE
, "Int", option ; WSManSessionOption
, "Ptr", data ; WSMAN_DATA*
, "UInt") ; return: DWORD●WSManSetSessionOption(session, option, data) = DLL("WsmSvc.dll", "dword WSManSetSessionOption(int, int, void*)")
# 呼び出し: WSManSetSessionOption(session, option, data)
# session : WSMAN_SESSION_HANDLE -> "int"
# option : WSManSessionOption -> "int"
# data : WSMAN_DATA* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "wsmsvc" fn WSManSetSessionOption(
session: isize, // WSMAN_SESSION_HANDLE
option: i32, // WSManSessionOption
data: [*c]WSMAN_DATA // WSMAN_DATA*
) callconv(std.os.windows.WINAPI) u32;proc WSManSetSessionOption(
session: int, # WSMAN_SESSION_HANDLE
option: int32, # WSManSessionOption
data: ptr WSMAN_DATA # WSMAN_DATA*
): uint32 {.importc: "WSManSetSessionOption", stdcall, dynlib: "WsmSvc.dll".}pragma(lib, "wsmsvc");
extern(Windows)
uint WSManSetSessionOption(
ptrdiff_t session, // WSMAN_SESSION_HANDLE
int option, // WSManSessionOption
WSMAN_DATA* data // WSMAN_DATA*
);ccall((:WSManSetSessionOption, "WsmSvc.dll"), stdcall, UInt32,
(Int, Int32, Ptr{WSMAN_DATA}),
session, option, data)
# session : WSMAN_SESSION_HANDLE -> Int
# option : WSManSessionOption -> Int32
# data : WSMAN_DATA* -> Ptr{WSMAN_DATA}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t WSManSetSessionOption(
intptr_t session,
int32_t option,
void* data);
]]
local wsmsvc = ffi.load("wsmsvc")
-- wsmsvc.WSManSetSessionOption(session, option, data)
-- session : WSMAN_SESSION_HANDLE
-- option : WSManSessionOption
-- data : WSMAN_DATA*
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('WsmSvc.dll');
const WSManSetSessionOption = lib.func('__stdcall', 'WSManSetSessionOption', 'uint32_t', ['intptr_t', 'int32_t', 'void *']);
// WSManSetSessionOption(session, option, data)
// session : WSMAN_SESSION_HANDLE -> 'intptr_t'
// option : WSManSessionOption -> 'int32_t'
// data : WSMAN_DATA* -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("WsmSvc.dll", {
WSManSetSessionOption: { parameters: ["isize", "i32", "pointer"], result: "u32" },
});
// lib.symbols.WSManSetSessionOption(session, option, data)
// session : WSMAN_SESSION_HANDLE -> "isize"
// option : WSManSessionOption -> "i32"
// data : WSMAN_DATA* -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t WSManSetSessionOption(
intptr_t session,
int32_t option,
void* data);
C, "WsmSvc.dll");
// $ffi->WSManSetSessionOption(session, option, data);
// session : WSMAN_SESSION_HANDLE
// option : WSManSessionOption
// data : WSMAN_DATA*
// 構造体/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 Wsmsvc extends StdCallLibrary {
Wsmsvc INSTANCE = Native.load("wsmsvc", Wsmsvc.class);
int WSManSetSessionOption(
long session, // WSMAN_SESSION_HANDLE
int option, // WSManSessionOption
Pointer data // WSMAN_DATA*
);
}@[Link("wsmsvc")]
lib LibWsmSvc
fun WSManSetSessionOption = WSManSetSessionOption(
session : LibC::SSizeT, # WSMAN_SESSION_HANDLE
option : Int32, # WSManSessionOption
data : WSMAN_DATA* # WSMAN_DATA*
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef WSManSetSessionOptionNative = Uint32 Function(IntPtr, Int32, Pointer<Void>);
typedef WSManSetSessionOptionDart = int Function(int, int, Pointer<Void>);
final WSManSetSessionOption = DynamicLibrary.open('WsmSvc.dll')
.lookupFunction<WSManSetSessionOptionNative, WSManSetSessionOptionDart>('WSManSetSessionOption');
// session : WSMAN_SESSION_HANDLE -> IntPtr
// option : WSManSessionOption -> Int32
// data : WSMAN_DATA* -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function WSManSetSessionOption(
session: NativeInt; // WSMAN_SESSION_HANDLE
option: Integer; // WSManSessionOption
data: Pointer // WSMAN_DATA*
): DWORD; stdcall;
external 'WsmSvc.dll' name 'WSManSetSessionOption';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "WSManSetSessionOption"
c_WSManSetSessionOption :: CIntPtr -> Int32 -> Ptr () -> IO Word32
-- session : WSMAN_SESSION_HANDLE -> CIntPtr
-- option : WSManSessionOption -> Int32
-- data : WSMAN_DATA* -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let wsmansetsessionoption =
foreign "WSManSetSessionOption"
(intptr_t @-> int32_t @-> (ptr void) @-> returning uint32_t)
(* session : WSMAN_SESSION_HANDLE -> intptr_t *)
(* option : WSManSessionOption -> int32_t *)
(* data : WSMAN_DATA* -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library wsmsvc (t "WsmSvc.dll"))
(cffi:use-foreign-library wsmsvc)
(cffi:defcfun ("WSManSetSessionOption" wsman-set-session-option :convention :stdcall) :uint32
(session :int64) ; WSMAN_SESSION_HANDLE
(option :int32) ; WSManSessionOption
(data :pointer)) ; WSMAN_DATA*
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $WSManSetSessionOption = Win32::API::More->new('WsmSvc',
'DWORD WSManSetSessionOption(LPARAM session, int option, LPVOID data)');
# my $ret = $WSManSetSessionOption->Call($session, $option, $data);
# session : WSMAN_SESSION_HANDLE -> LPARAM
# option : WSManSessionOption -> int
# data : WSMAN_DATA* -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。