ホーム › System.RemoteManagement › WSManConnectShellCommand
WSManConnectShellCommand
関数既存のリモートコマンドへ接続する。
シグネチャ
// WsmSvc.dll
#include <windows.h>
void WSManConnectShellCommand(
WSMAN_SHELL_HANDLE shell,
DWORD flags,
LPCWSTR commandID,
WSMAN_OPTION_SET* options, // optional
WSMAN_DATA* connectXml, // optional
WSMAN_SHELL_ASYNC* async,
WSMAN_COMMAND_HANDLE* command
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| shell | WSMAN_SHELL_HANDLE | in | 接続先のシェルハンドル。 |
| flags | DWORD | in | 接続動作を制御するフラグ。 |
| commandID | LPCWSTR | in | 接続する既存コマンドを識別するコマンドID文字列。 |
| options | WSMAN_OPTION_SET* | inoptional | コマンドに渡すオプションセットへのポインター。NULL 可。 |
| connectXml | WSMAN_DATA* | inoptional | 接続用のXMLデータを格納した構造体へのポインター。NULL 可。 |
| async | WSMAN_SHELL_ASYNC* | in | 完了通知を受け取る非同期コールバック構造体へのポインター。 |
| command | WSMAN_COMMAND_HANDLE* | out | 接続されたコマンドハンドルを受け取るポインター。 |
戻り値の型: void
各言語での呼び出し定義
// WsmSvc.dll
#include <windows.h>
void WSManConnectShellCommand(
WSMAN_SHELL_HANDLE shell,
DWORD flags,
LPCWSTR commandID,
WSMAN_OPTION_SET* options, // optional
WSMAN_DATA* connectXml, // optional
WSMAN_SHELL_ASYNC* async,
WSMAN_COMMAND_HANDLE* command
);[DllImport("WsmSvc.dll", ExactSpelling = true)]
static extern void WSManConnectShellCommand(
IntPtr shell, // WSMAN_SHELL_HANDLE
uint flags, // DWORD
[MarshalAs(UnmanagedType.LPWStr)] string commandID, // LPCWSTR
IntPtr options, // WSMAN_OPTION_SET* optional
IntPtr connectXml, // WSMAN_DATA* optional
IntPtr async, // WSMAN_SHELL_ASYNC*
out IntPtr command // WSMAN_COMMAND_HANDLE* out
);<DllImport("WsmSvc.dll", ExactSpelling:=True)>
Public Shared Sub WSManConnectShellCommand(
shell As IntPtr, ' WSMAN_SHELL_HANDLE
flags As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPWStr)> commandID As String, ' LPCWSTR
options As IntPtr, ' WSMAN_OPTION_SET* optional
connectXml As IntPtr, ' WSMAN_DATA* optional
async As IntPtr, ' WSMAN_SHELL_ASYNC*
<Out> ByRef command As IntPtr ' WSMAN_COMMAND_HANDLE* out
)
End Sub' shell : WSMAN_SHELL_HANDLE
' flags : DWORD
' commandID : LPCWSTR
' options : WSMAN_OPTION_SET* optional
' connectXml : WSMAN_DATA* optional
' async : WSMAN_SHELL_ASYNC*
' command : WSMAN_COMMAND_HANDLE* out
Declare PtrSafe Sub WSManConnectShellCommand Lib "wsmsvc" ( _
ByVal shell As LongPtr, _
ByVal flags As Long, _
ByVal commandID As LongPtr, _
ByVal options As LongPtr, _
ByVal connectXml As LongPtr, _
ByVal async As LongPtr, _
ByRef command As LongPtr)
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
WSManConnectShellCommand = ctypes.windll.wsmsvc.WSManConnectShellCommand
WSManConnectShellCommand.restype = None
WSManConnectShellCommand.argtypes = [
ctypes.c_ssize_t, # shell : WSMAN_SHELL_HANDLE
wintypes.DWORD, # flags : DWORD
wintypes.LPCWSTR, # commandID : LPCWSTR
ctypes.c_void_p, # options : WSMAN_OPTION_SET* optional
ctypes.c_void_p, # connectXml : WSMAN_DATA* optional
ctypes.c_void_p, # async : WSMAN_SHELL_ASYNC*
ctypes.c_void_p, # command : WSMAN_COMMAND_HANDLE* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WsmSvc.dll')
WSManConnectShellCommand = Fiddle::Function.new(
lib['WSManConnectShellCommand'],
[
Fiddle::TYPE_INTPTR_T, # shell : WSMAN_SHELL_HANDLE
-Fiddle::TYPE_INT, # flags : DWORD
Fiddle::TYPE_VOIDP, # commandID : LPCWSTR
Fiddle::TYPE_VOIDP, # options : WSMAN_OPTION_SET* optional
Fiddle::TYPE_VOIDP, # connectXml : WSMAN_DATA* optional
Fiddle::TYPE_VOIDP, # async : WSMAN_SHELL_ASYNC*
Fiddle::TYPE_VOIDP, # command : WSMAN_COMMAND_HANDLE* out
],
Fiddle::TYPE_VOID)#[link(name = "wsmsvc")]
extern "system" {
fn WSManConnectShellCommand(
shell: isize, // WSMAN_SHELL_HANDLE
flags: u32, // DWORD
commandID: *const u16, // LPCWSTR
options: *mut WSMAN_OPTION_SET, // WSMAN_OPTION_SET* optional
connectXml: *mut WSMAN_DATA, // WSMAN_DATA* optional
async: *mut WSMAN_SHELL_ASYNC, // WSMAN_SHELL_ASYNC*
command: *mut isize // WSMAN_COMMAND_HANDLE* out
);
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("WsmSvc.dll")]
public static extern void WSManConnectShellCommand(IntPtr shell, uint flags, [MarshalAs(UnmanagedType.LPWStr)] string commandID, IntPtr options, IntPtr connectXml, IntPtr async, out IntPtr command);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WsmSvc_WSManConnectShellCommand' -Namespace Win32 -PassThru
# $api::WSManConnectShellCommand(shell, flags, commandID, options, connectXml, async, command)#uselib "WsmSvc.dll"
#func global WSManConnectShellCommand "WSManConnectShellCommand" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; WSManConnectShellCommand shell, flags, commandID, varptr(options), varptr(connectXml), varptr(async), varptr(command)
; shell : WSMAN_SHELL_HANDLE -> "sptr"
; flags : DWORD -> "sptr"
; commandID : LPCWSTR -> "sptr"
; options : WSMAN_OPTION_SET* optional -> "sptr"
; connectXml : WSMAN_DATA* optional -> "sptr"
; async : WSMAN_SHELL_ASYNC* -> "sptr"
; command : WSMAN_COMMAND_HANDLE* out -> "sptr"出力引数:
#uselib "WsmSvc.dll" #func global WSManConnectShellCommand "WSManConnectShellCommand" sptr, int, wstr, var, var, var, var ; WSManConnectShellCommand shell, flags, commandID, options, connectXml, async, command ; shell : WSMAN_SHELL_HANDLE -> "sptr" ; flags : DWORD -> "int" ; commandID : LPCWSTR -> "wstr" ; options : WSMAN_OPTION_SET* optional -> "var" ; connectXml : WSMAN_DATA* optional -> "var" ; async : WSMAN_SHELL_ASYNC* -> "var" ; command : WSMAN_COMMAND_HANDLE* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "WsmSvc.dll" #func global WSManConnectShellCommand "WSManConnectShellCommand" sptr, int, wstr, sptr, sptr, sptr, sptr ; WSManConnectShellCommand shell, flags, commandID, varptr(options), varptr(connectXml), varptr(async), varptr(command) ; shell : WSMAN_SHELL_HANDLE -> "sptr" ; flags : DWORD -> "int" ; commandID : LPCWSTR -> "wstr" ; options : WSMAN_OPTION_SET* optional -> "sptr" ; connectXml : WSMAN_DATA* optional -> "sptr" ; async : WSMAN_SHELL_ASYNC* -> "sptr" ; command : WSMAN_COMMAND_HANDLE* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; void WSManConnectShellCommand(WSMAN_SHELL_HANDLE shell, DWORD flags, LPCWSTR commandID, WSMAN_OPTION_SET* options, WSMAN_DATA* connectXml, WSMAN_SHELL_ASYNC* async, WSMAN_COMMAND_HANDLE* command) #uselib "WsmSvc.dll" #func global WSManConnectShellCommand "WSManConnectShellCommand" intptr, int, wstr, var, var, var, var ; WSManConnectShellCommand shell, flags, commandID, options, connectXml, async, command ; shell : WSMAN_SHELL_HANDLE -> "intptr" ; flags : DWORD -> "int" ; commandID : LPCWSTR -> "wstr" ; options : WSMAN_OPTION_SET* optional -> "var" ; connectXml : WSMAN_DATA* optional -> "var" ; async : WSMAN_SHELL_ASYNC* -> "var" ; command : WSMAN_COMMAND_HANDLE* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; void WSManConnectShellCommand(WSMAN_SHELL_HANDLE shell, DWORD flags, LPCWSTR commandID, WSMAN_OPTION_SET* options, WSMAN_DATA* connectXml, WSMAN_SHELL_ASYNC* async, WSMAN_COMMAND_HANDLE* command) #uselib "WsmSvc.dll" #func global WSManConnectShellCommand "WSManConnectShellCommand" intptr, int, wstr, intptr, intptr, intptr, intptr ; WSManConnectShellCommand shell, flags, commandID, varptr(options), varptr(connectXml), varptr(async), varptr(command) ; shell : WSMAN_SHELL_HANDLE -> "intptr" ; flags : DWORD -> "int" ; commandID : LPCWSTR -> "wstr" ; options : WSMAN_OPTION_SET* optional -> "intptr" ; connectXml : WSMAN_DATA* optional -> "intptr" ; async : WSMAN_SHELL_ASYNC* -> "intptr" ; command : WSMAN_COMMAND_HANDLE* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wsmsvc = windows.NewLazySystemDLL("WsmSvc.dll")
procWSManConnectShellCommand = wsmsvc.NewProc("WSManConnectShellCommand")
)
// shell (WSMAN_SHELL_HANDLE), flags (DWORD), commandID (LPCWSTR), options (WSMAN_OPTION_SET* optional), connectXml (WSMAN_DATA* optional), async (WSMAN_SHELL_ASYNC*), command (WSMAN_COMMAND_HANDLE* out)
r1, _, err := procWSManConnectShellCommand.Call(
uintptr(shell),
uintptr(flags),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(commandID))),
uintptr(options),
uintptr(connectXml),
uintptr(async),
uintptr(command),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // voidprocedure WSManConnectShellCommand(
shell: NativeInt; // WSMAN_SHELL_HANDLE
flags: DWORD; // DWORD
commandID: PWideChar; // LPCWSTR
options: Pointer; // WSMAN_OPTION_SET* optional
connectXml: Pointer; // WSMAN_DATA* optional
async: Pointer; // WSMAN_SHELL_ASYNC*
command: Pointer // WSMAN_COMMAND_HANDLE* out
); stdcall;
external 'WsmSvc.dll' name 'WSManConnectShellCommand';result := DllCall("WsmSvc\WSManConnectShellCommand"
, "Ptr", shell ; WSMAN_SHELL_HANDLE
, "UInt", flags ; DWORD
, "WStr", commandID ; LPCWSTR
, "Ptr", options ; WSMAN_OPTION_SET* optional
, "Ptr", connectXml ; WSMAN_DATA* optional
, "Ptr", async ; WSMAN_SHELL_ASYNC*
, "Ptr", command ; WSMAN_COMMAND_HANDLE* out
, "Int") ; return: void●WSManConnectShellCommand(shell, flags, commandID, options, connectXml, async, command) = DLL("WsmSvc.dll", "int WSManConnectShellCommand(int, dword, char*, void*, void*, void*, void*)")
# 呼び出し: WSManConnectShellCommand(shell, flags, commandID, options, connectXml, async, command)
# shell : WSMAN_SHELL_HANDLE -> "int"
# flags : DWORD -> "dword"
# commandID : LPCWSTR -> "char*"
# options : WSMAN_OPTION_SET* optional -> "void*"
# connectXml : WSMAN_DATA* optional -> "void*"
# async : WSMAN_SHELL_ASYNC* -> "void*"
# command : WSMAN_COMMAND_HANDLE* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "wsmsvc" fn WSManConnectShellCommand(
shell: isize, // WSMAN_SHELL_HANDLE
flags: u32, // DWORD
commandID: [*c]const u16, // LPCWSTR
options: [*c]WSMAN_OPTION_SET, // WSMAN_OPTION_SET* optional
connectXml: [*c]WSMAN_DATA, // WSMAN_DATA* optional
async: [*c]WSMAN_SHELL_ASYNC, // WSMAN_SHELL_ASYNC*
command: [*c]isize // WSMAN_COMMAND_HANDLE* out
) callconv(std.os.windows.WINAPI) void;proc WSManConnectShellCommand(
shell: int, # WSMAN_SHELL_HANDLE
flags: uint32, # DWORD
commandID: WideCString, # LPCWSTR
options: ptr WSMAN_OPTION_SET, # WSMAN_OPTION_SET* optional
connectXml: ptr WSMAN_DATA, # WSMAN_DATA* optional
async: ptr WSMAN_SHELL_ASYNC, # WSMAN_SHELL_ASYNC*
command: ptr int # WSMAN_COMMAND_HANDLE* out
) {.importc: "WSManConnectShellCommand", stdcall, dynlib: "WsmSvc.dll".}pragma(lib, "wsmsvc");
extern(Windows)
void WSManConnectShellCommand(
ptrdiff_t shell, // WSMAN_SHELL_HANDLE
uint flags, // DWORD
const(wchar)* commandID, // LPCWSTR
WSMAN_OPTION_SET* options, // WSMAN_OPTION_SET* optional
WSMAN_DATA* connectXml, // WSMAN_DATA* optional
WSMAN_SHELL_ASYNC* async, // WSMAN_SHELL_ASYNC*
ptrdiff_t* command // WSMAN_COMMAND_HANDLE* out
);ccall((:WSManConnectShellCommand, "WsmSvc.dll"), stdcall, Cvoid,
(Int, UInt32, Cwstring, Ptr{WSMAN_OPTION_SET}, Ptr{WSMAN_DATA}, Ptr{WSMAN_SHELL_ASYNC}, Ptr{Int}),
shell, flags, commandID, options, connectXml, async, command)
# shell : WSMAN_SHELL_HANDLE -> Int
# flags : DWORD -> UInt32
# commandID : LPCWSTR -> Cwstring
# options : WSMAN_OPTION_SET* optional -> Ptr{WSMAN_OPTION_SET}
# connectXml : WSMAN_DATA* optional -> Ptr{WSMAN_DATA}
# async : WSMAN_SHELL_ASYNC* -> Ptr{WSMAN_SHELL_ASYNC}
# command : WSMAN_COMMAND_HANDLE* out -> Ptr{Int}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
void WSManConnectShellCommand(
intptr_t shell,
uint32_t flags,
const uint16_t* commandID,
void* options,
void* connectXml,
void* async,
intptr_t* command);
]]
local wsmsvc = ffi.load("wsmsvc")
-- wsmsvc.WSManConnectShellCommand(shell, flags, commandID, options, connectXml, async, command)
-- shell : WSMAN_SHELL_HANDLE
-- flags : DWORD
-- commandID : LPCWSTR
-- options : WSMAN_OPTION_SET* optional
-- connectXml : WSMAN_DATA* optional
-- async : WSMAN_SHELL_ASYNC*
-- command : WSMAN_COMMAND_HANDLE* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('WsmSvc.dll');
const WSManConnectShellCommand = lib.func('__stdcall', 'WSManConnectShellCommand', 'void', ['intptr_t', 'uint32_t', 'str16', 'void *', 'void *', 'void *', 'intptr_t *']);
// WSManConnectShellCommand(shell, flags, commandID, options, connectXml, async, command)
// shell : WSMAN_SHELL_HANDLE -> 'intptr_t'
// flags : DWORD -> 'uint32_t'
// commandID : LPCWSTR -> 'str16'
// options : WSMAN_OPTION_SET* optional -> 'void *'
// connectXml : WSMAN_DATA* optional -> 'void *'
// async : WSMAN_SHELL_ASYNC* -> 'void *'
// command : WSMAN_COMMAND_HANDLE* out -> 'intptr_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("WsmSvc.dll", {
WSManConnectShellCommand: { parameters: ["isize", "u32", "buffer", "pointer", "pointer", "pointer", "pointer"], result: "void" },
});
// lib.symbols.WSManConnectShellCommand(shell, flags, commandID, options, connectXml, async, command)
// shell : WSMAN_SHELL_HANDLE -> "isize"
// flags : DWORD -> "u32"
// commandID : LPCWSTR -> "buffer"
// options : WSMAN_OPTION_SET* optional -> "pointer"
// connectXml : WSMAN_DATA* optional -> "pointer"
// async : WSMAN_SHELL_ASYNC* -> "pointer"
// command : WSMAN_COMMAND_HANDLE* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
void WSManConnectShellCommand(
intptr_t shell,
uint32_t flags,
const uint16_t* commandID,
void* options,
void* connectXml,
void* async,
intptr_t* command);
C, "WsmSvc.dll");
// $ffi->WSManConnectShellCommand(shell, flags, commandID, options, connectXml, async, command);
// shell : WSMAN_SHELL_HANDLE
// flags : DWORD
// commandID : LPCWSTR
// options : WSMAN_OPTION_SET* optional
// connectXml : WSMAN_DATA* optional
// async : WSMAN_SHELL_ASYNC*
// command : WSMAN_COMMAND_HANDLE* out
// 構造体/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);
void WSManConnectShellCommand(
long shell, // WSMAN_SHELL_HANDLE
int flags, // DWORD
WString commandID, // LPCWSTR
Pointer options, // WSMAN_OPTION_SET* optional
Pointer connectXml, // WSMAN_DATA* optional
Pointer async, // WSMAN_SHELL_ASYNC*
LongByReference command // WSMAN_COMMAND_HANDLE* out
);
}@[Link("wsmsvc")]
lib LibWsmSvc
fun WSManConnectShellCommand = WSManConnectShellCommand(
shell : LibC::SSizeT, # WSMAN_SHELL_HANDLE
flags : UInt32, # DWORD
commandID : UInt16*, # LPCWSTR
options : WSMAN_OPTION_SET*, # WSMAN_OPTION_SET* optional
connectXml : WSMAN_DATA*, # WSMAN_DATA* optional
async : WSMAN_SHELL_ASYNC*, # WSMAN_SHELL_ASYNC*
command : LibC::SSizeT* # WSMAN_COMMAND_HANDLE* out
) : Void
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef WSManConnectShellCommandNative = Void Function(IntPtr, Uint32, Pointer<Utf16>, Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<IntPtr>);
typedef WSManConnectShellCommandDart = void Function(int, int, Pointer<Utf16>, Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<IntPtr>);
final WSManConnectShellCommand = DynamicLibrary.open('WsmSvc.dll')
.lookupFunction<WSManConnectShellCommandNative, WSManConnectShellCommandDart>('WSManConnectShellCommand');
// shell : WSMAN_SHELL_HANDLE -> IntPtr
// flags : DWORD -> Uint32
// commandID : LPCWSTR -> Pointer<Utf16>
// options : WSMAN_OPTION_SET* optional -> Pointer<Void>
// connectXml : WSMAN_DATA* optional -> Pointer<Void>
// async : WSMAN_SHELL_ASYNC* -> Pointer<Void>
// command : WSMAN_COMMAND_HANDLE* out -> Pointer<IntPtr>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
procedure WSManConnectShellCommand(
shell: NativeInt; // WSMAN_SHELL_HANDLE
flags: DWORD; // DWORD
commandID: PWideChar; // LPCWSTR
options: Pointer; // WSMAN_OPTION_SET* optional
connectXml: Pointer; // WSMAN_DATA* optional
async: Pointer; // WSMAN_SHELL_ASYNC*
command: Pointer // WSMAN_COMMAND_HANDLE* out
); stdcall;
external 'WsmSvc.dll' name 'WSManConnectShellCommand';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "WSManConnectShellCommand"
c_WSManConnectShellCommand :: CIntPtr -> Word32 -> CWString -> Ptr () -> Ptr () -> Ptr () -> Ptr CIntPtr -> IO ()
-- shell : WSMAN_SHELL_HANDLE -> CIntPtr
-- flags : DWORD -> Word32
-- commandID : LPCWSTR -> CWString
-- options : WSMAN_OPTION_SET* optional -> Ptr ()
-- connectXml : WSMAN_DATA* optional -> Ptr ()
-- async : WSMAN_SHELL_ASYNC* -> Ptr ()
-- command : WSMAN_COMMAND_HANDLE* out -> Ptr CIntPtr
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let wsmanconnectshellcommand =
foreign "WSManConnectShellCommand"
(intptr_t @-> uint32_t @-> (ptr uint16_t) @-> (ptr void) @-> (ptr void) @-> (ptr void) @-> (ptr intptr_t) @-> returning void)
(* shell : WSMAN_SHELL_HANDLE -> intptr_t *)
(* flags : DWORD -> uint32_t *)
(* commandID : LPCWSTR -> (ptr uint16_t) *)
(* options : WSMAN_OPTION_SET* optional -> (ptr void) *)
(* connectXml : WSMAN_DATA* optional -> (ptr void) *)
(* async : WSMAN_SHELL_ASYNC* -> (ptr void) *)
(* command : WSMAN_COMMAND_HANDLE* out -> (ptr intptr_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library wsmsvc (t "WsmSvc.dll"))
(cffi:use-foreign-library wsmsvc)
(cffi:defcfun ("WSManConnectShellCommand" wsman-connect-shell-command :convention :stdcall) :void
(shell :int64) ; WSMAN_SHELL_HANDLE
(flags :uint32) ; DWORD
(command-id (:string :encoding :utf-16le)) ; LPCWSTR
(options :pointer) ; WSMAN_OPTION_SET* optional
(connect-xml :pointer) ; WSMAN_DATA* optional
(async :pointer) ; WSMAN_SHELL_ASYNC*
(command :pointer)) ; WSMAN_COMMAND_HANDLE* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $WSManConnectShellCommand = Win32::API::More->new('WsmSvc',
'void WSManConnectShellCommand(LPARAM shell, DWORD flags, LPCWSTR commandID, LPVOID options, LPVOID connectXml, LPVOID async, LPVOID command)');
# my $ret = $WSManConnectShellCommand->Call($shell, $flags, $commandID, $options, $connectXml, $async, $command);
# shell : WSMAN_SHELL_HANDLE -> LPARAM
# flags : DWORD -> DWORD
# commandID : LPCWSTR -> LPCWSTR
# options : WSMAN_OPTION_SET* optional -> LPVOID
# connectXml : WSMAN_DATA* optional -> LPVOID
# async : WSMAN_SHELL_ASYNC* -> LPVOID
# command : WSMAN_COMMAND_HANDLE* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。