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

WSManCloseOperation

関数
WS-Manの非同期操作をキャンセルし閉じる。
DLLWsmSvc.dll呼出規約winapi対応OSWindows 7 以降

シグネチャ

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

DWORD WSManCloseOperation(
    WSMAN_OPERATION_HANDLE operationHandle,   // optional
    DWORD flags
);

パラメーター

名前方向説明
operationHandleWSMAN_OPERATION_HANDLEinoptional閉じる対象の非同期操作ハンドル。
flagsDWORDin予約済み。0 を指定する。

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD WSManCloseOperation(
    WSMAN_OPERATION_HANDLE operationHandle,   // optional
    DWORD flags
);
[DllImport("WsmSvc.dll", ExactSpelling = true)]
static extern uint WSManCloseOperation(
    IntPtr operationHandle,   // WSMAN_OPERATION_HANDLE optional
    uint flags   // DWORD
);
<DllImport("WsmSvc.dll", ExactSpelling:=True)>
Public Shared Function WSManCloseOperation(
    operationHandle As IntPtr,   ' WSMAN_OPERATION_HANDLE optional
    flags As UInteger   ' DWORD
) As UInteger
End Function
' operationHandle : WSMAN_OPERATION_HANDLE optional
' flags : DWORD
Declare PtrSafe Function WSManCloseOperation Lib "wsmsvc" ( _
    ByVal operationHandle As LongPtr, _
    ByVal flags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WSManCloseOperation = ctypes.windll.wsmsvc.WSManCloseOperation
WSManCloseOperation.restype = wintypes.DWORD
WSManCloseOperation.argtypes = [
    ctypes.c_ssize_t,  # operationHandle : WSMAN_OPERATION_HANDLE optional
    wintypes.DWORD,  # flags : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WsmSvc.dll')
WSManCloseOperation = Fiddle::Function.new(
  lib['WSManCloseOperation'],
  [
    Fiddle::TYPE_INTPTR_T,  # operationHandle : WSMAN_OPERATION_HANDLE optional
    -Fiddle::TYPE_INT,  # flags : DWORD
  ],
  -Fiddle::TYPE_INT)
#[link(name = "wsmsvc")]
extern "system" {
    fn WSManCloseOperation(
        operationHandle: isize,  // WSMAN_OPERATION_HANDLE optional
        flags: u32  // DWORD
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("WsmSvc.dll")]
public static extern uint WSManCloseOperation(IntPtr operationHandle, uint flags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WsmSvc_WSManCloseOperation' -Namespace Win32 -PassThru
# $api::WSManCloseOperation(operationHandle, flags)
#uselib "WsmSvc.dll"
#func global WSManCloseOperation "WSManCloseOperation" sptr, sptr
; WSManCloseOperation operationHandle, flags   ; 戻り値は stat
; operationHandle : WSMAN_OPERATION_HANDLE optional -> "sptr"
; flags : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "WsmSvc.dll"
#cfunc global WSManCloseOperation "WSManCloseOperation" sptr, int
; res = WSManCloseOperation(operationHandle, flags)
; operationHandle : WSMAN_OPERATION_HANDLE optional -> "sptr"
; flags : DWORD -> "int"
; DWORD WSManCloseOperation(WSMAN_OPERATION_HANDLE operationHandle, DWORD flags)
#uselib "WsmSvc.dll"
#cfunc global WSManCloseOperation "WSManCloseOperation" intptr, int
; res = WSManCloseOperation(operationHandle, flags)
; operationHandle : WSMAN_OPERATION_HANDLE optional -> "intptr"
; flags : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wsmsvc = windows.NewLazySystemDLL("WsmSvc.dll")
	procWSManCloseOperation = wsmsvc.NewProc("WSManCloseOperation")
)

// operationHandle (WSMAN_OPERATION_HANDLE optional), flags (DWORD)
r1, _, err := procWSManCloseOperation.Call(
	uintptr(operationHandle),
	uintptr(flags),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function WSManCloseOperation(
  operationHandle: NativeInt;   // WSMAN_OPERATION_HANDLE optional
  flags: DWORD   // DWORD
): DWORD; stdcall;
  external 'WsmSvc.dll' name 'WSManCloseOperation';
result := DllCall("WsmSvc\WSManCloseOperation"
    , "Ptr", operationHandle   ; WSMAN_OPERATION_HANDLE optional
    , "UInt", flags   ; DWORD
    , "UInt")   ; return: DWORD
●WSManCloseOperation(operationHandle, flags) = DLL("WsmSvc.dll", "dword WSManCloseOperation(int, dword)")
# 呼び出し: WSManCloseOperation(operationHandle, flags)
# operationHandle : WSMAN_OPERATION_HANDLE optional -> "int"
# flags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "wsmsvc" fn WSManCloseOperation(
    operationHandle: isize, // WSMAN_OPERATION_HANDLE optional
    flags: u32 // DWORD
) callconv(std.os.windows.WINAPI) u32;
proc WSManCloseOperation(
    operationHandle: int,  # WSMAN_OPERATION_HANDLE optional
    flags: uint32  # DWORD
): uint32 {.importc: "WSManCloseOperation", stdcall, dynlib: "WsmSvc.dll".}
pragma(lib, "wsmsvc");
extern(Windows)
uint WSManCloseOperation(
    ptrdiff_t operationHandle,   // WSMAN_OPERATION_HANDLE optional
    uint flags   // DWORD
);
ccall((:WSManCloseOperation, "WsmSvc.dll"), stdcall, UInt32,
      (Int, UInt32),
      operationHandle, flags)
# operationHandle : WSMAN_OPERATION_HANDLE optional -> Int
# flags : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
uint32_t WSManCloseOperation(
    intptr_t operationHandle,
    uint32_t flags);
]]
local wsmsvc = ffi.load("wsmsvc")
-- wsmsvc.WSManCloseOperation(operationHandle, flags)
-- operationHandle : WSMAN_OPERATION_HANDLE optional
-- flags : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('WsmSvc.dll');
const WSManCloseOperation = lib.func('__stdcall', 'WSManCloseOperation', 'uint32_t', ['intptr_t', 'uint32_t']);
// WSManCloseOperation(operationHandle, flags)
// operationHandle : WSMAN_OPERATION_HANDLE optional -> 'intptr_t'
// flags : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("WsmSvc.dll", {
  WSManCloseOperation: { parameters: ["isize", "u32"], result: "u32" },
});
// lib.symbols.WSManCloseOperation(operationHandle, flags)
// operationHandle : WSMAN_OPERATION_HANDLE optional -> "isize"
// flags : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t WSManCloseOperation(
    intptr_t operationHandle,
    uint32_t flags);
C, "WsmSvc.dll");
// $ffi->WSManCloseOperation(operationHandle, flags);
// operationHandle : WSMAN_OPERATION_HANDLE optional
// flags : DWORD
// 構造体/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 WSManCloseOperation(
        long operationHandle,   // WSMAN_OPERATION_HANDLE optional
        int flags   // DWORD
    );
}
@[Link("wsmsvc")]
lib LibWsmSvc
  fun WSManCloseOperation = WSManCloseOperation(
    operationHandle : LibC::SSizeT,   # WSMAN_OPERATION_HANDLE optional
    flags : UInt32   # DWORD
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef WSManCloseOperationNative = Uint32 Function(IntPtr, Uint32);
typedef WSManCloseOperationDart = int Function(int, int);
final WSManCloseOperation = DynamicLibrary.open('WsmSvc.dll')
    .lookupFunction<WSManCloseOperationNative, WSManCloseOperationDart>('WSManCloseOperation');
// operationHandle : WSMAN_OPERATION_HANDLE optional -> IntPtr
// flags : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function WSManCloseOperation(
  operationHandle: NativeInt;   // WSMAN_OPERATION_HANDLE optional
  flags: DWORD   // DWORD
): DWORD; stdcall;
  external 'WsmSvc.dll' name 'WSManCloseOperation';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "WSManCloseOperation"
  c_WSManCloseOperation :: CIntPtr -> Word32 -> IO Word32
-- operationHandle : WSMAN_OPERATION_HANDLE optional -> CIntPtr
-- flags : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let wsmancloseoperation =
  foreign "WSManCloseOperation"
    (intptr_t @-> uint32_t @-> returning uint32_t)
(* operationHandle : WSMAN_OPERATION_HANDLE optional -> intptr_t *)
(* flags : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library wsmsvc (t "WsmSvc.dll"))
(cffi:use-foreign-library wsmsvc)

(cffi:defcfun ("WSManCloseOperation" wsman-close-operation :convention :stdcall) :uint32
  (operation-handle :int64)   ; WSMAN_OPERATION_HANDLE optional
  (flags :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $WSManCloseOperation = Win32::API::More->new('WsmSvc',
    'DWORD WSManCloseOperation(LPARAM operationHandle, DWORD flags)');
# my $ret = $WSManCloseOperation->Call($operationHandle, $flags);
# operationHandle : WSMAN_OPERATION_HANDLE optional -> LPARAM
# flags : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。