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

HcsWaitForOperationResult

関数
HCS操作の完了を待ち結果を取得する。
DLLcomputecore.dll呼出規約winapi

シグネチャ

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

HRESULT HcsWaitForOperationResult(
    HCS_OPERATION operation,
    DWORD timeoutMs,
    LPWSTR* resultDocument   // optional
);

パラメーター

名前方向説明
operationHCS_OPERATIONin完了を待機する対象のHCS操作ハンドル。
timeoutMsDWORDin待機する最大時間をミリ秒で指定する。INFINITEで無制限待機。
resultDocumentLPWSTR*outoptional操作結果のJSON文書を受け取るポインタ。要解放。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT HcsWaitForOperationResult(
    HCS_OPERATION operation,
    DWORD timeoutMs,
    LPWSTR* resultDocument   // optional
);
[DllImport("computecore.dll", ExactSpelling = true)]
static extern int HcsWaitForOperationResult(
    IntPtr operation,   // HCS_OPERATION
    uint timeoutMs,   // DWORD
    IntPtr resultDocument   // LPWSTR* optional, out
);
<DllImport("computecore.dll", ExactSpelling:=True)>
Public Shared Function HcsWaitForOperationResult(
    operation As IntPtr,   ' HCS_OPERATION
    timeoutMs As UInteger,   ' DWORD
    resultDocument As IntPtr   ' LPWSTR* optional, out
) As Integer
End Function
' operation : HCS_OPERATION
' timeoutMs : DWORD
' resultDocument : LPWSTR* optional, out
Declare PtrSafe Function HcsWaitForOperationResult Lib "computecore" ( _
    ByVal operation As LongPtr, _
    ByVal timeoutMs As Long, _
    ByVal resultDocument As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

HcsWaitForOperationResult = ctypes.windll.computecore.HcsWaitForOperationResult
HcsWaitForOperationResult.restype = ctypes.c_int
HcsWaitForOperationResult.argtypes = [
    wintypes.HANDLE,  # operation : HCS_OPERATION
    wintypes.DWORD,  # timeoutMs : DWORD
    ctypes.c_void_p,  # resultDocument : LPWSTR* optional, out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('computecore.dll')
HcsWaitForOperationResult = Fiddle::Function.new(
  lib['HcsWaitForOperationResult'],
  [
    Fiddle::TYPE_VOIDP,  # operation : HCS_OPERATION
    -Fiddle::TYPE_INT,  # timeoutMs : DWORD
    Fiddle::TYPE_VOIDP,  # resultDocument : LPWSTR* optional, out
  ],
  Fiddle::TYPE_INT)
#[link(name = "computecore")]
extern "system" {
    fn HcsWaitForOperationResult(
        operation: *mut core::ffi::c_void,  // HCS_OPERATION
        timeoutMs: u32,  // DWORD
        resultDocument: *mut *mut u16  // LPWSTR* optional, out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("computecore.dll")]
public static extern int HcsWaitForOperationResult(IntPtr operation, uint timeoutMs, IntPtr resultDocument);
"@
$api = Add-Type -MemberDefinition $sig -Name 'computecore_HcsWaitForOperationResult' -Namespace Win32 -PassThru
# $api::HcsWaitForOperationResult(operation, timeoutMs, resultDocument)
#uselib "computecore.dll"
#func global HcsWaitForOperationResult "HcsWaitForOperationResult" sptr, sptr, sptr
; HcsWaitForOperationResult operation, timeoutMs, varptr(resultDocument)   ; 戻り値は stat
; operation : HCS_OPERATION -> "sptr"
; timeoutMs : DWORD -> "sptr"
; resultDocument : LPWSTR* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "computecore.dll"
#cfunc global HcsWaitForOperationResult "HcsWaitForOperationResult" sptr, int, var
; res = HcsWaitForOperationResult(operation, timeoutMs, resultDocument)
; operation : HCS_OPERATION -> "sptr"
; timeoutMs : DWORD -> "int"
; resultDocument : LPWSTR* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT HcsWaitForOperationResult(HCS_OPERATION operation, DWORD timeoutMs, LPWSTR* resultDocument)
#uselib "computecore.dll"
#cfunc global HcsWaitForOperationResult "HcsWaitForOperationResult" intptr, int, var
; res = HcsWaitForOperationResult(operation, timeoutMs, resultDocument)
; operation : HCS_OPERATION -> "intptr"
; timeoutMs : DWORD -> "int"
; resultDocument : LPWSTR* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	computecore = windows.NewLazySystemDLL("computecore.dll")
	procHcsWaitForOperationResult = computecore.NewProc("HcsWaitForOperationResult")
)

// operation (HCS_OPERATION), timeoutMs (DWORD), resultDocument (LPWSTR* optional, out)
r1, _, err := procHcsWaitForOperationResult.Call(
	uintptr(operation),
	uintptr(timeoutMs),
	uintptr(resultDocument),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function HcsWaitForOperationResult(
  operation: THandle;   // HCS_OPERATION
  timeoutMs: DWORD;   // DWORD
  resultDocument: PPWideChar   // LPWSTR* optional, out
): Integer; stdcall;
  external 'computecore.dll' name 'HcsWaitForOperationResult';
result := DllCall("computecore\HcsWaitForOperationResult"
    , "Ptr", operation   ; HCS_OPERATION
    , "UInt", timeoutMs   ; DWORD
    , "Ptr", resultDocument   ; LPWSTR* optional, out
    , "Int")   ; return: HRESULT
●HcsWaitForOperationResult(operation, timeoutMs, resultDocument) = DLL("computecore.dll", "int HcsWaitForOperationResult(void*, dword, void*)")
# 呼び出し: HcsWaitForOperationResult(operation, timeoutMs, resultDocument)
# operation : HCS_OPERATION -> "void*"
# timeoutMs : DWORD -> "dword"
# resultDocument : LPWSTR* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "computecore" fn HcsWaitForOperationResult(
    operation: ?*anyopaque, // HCS_OPERATION
    timeoutMs: u32, // DWORD
    resultDocument: [*c][*c]u16 // LPWSTR* optional, out
) callconv(std.os.windows.WINAPI) i32;
proc HcsWaitForOperationResult(
    operation: pointer,  # HCS_OPERATION
    timeoutMs: uint32,  # DWORD
    resultDocument: ptr WideCString  # LPWSTR* optional, out
): int32 {.importc: "HcsWaitForOperationResult", stdcall, dynlib: "computecore.dll".}
pragma(lib, "computecore");
extern(Windows)
int HcsWaitForOperationResult(
    void* operation,   // HCS_OPERATION
    uint timeoutMs,   // DWORD
    wchar** resultDocument   // LPWSTR* optional, out
);
ccall((:HcsWaitForOperationResult, "computecore.dll"), stdcall, Int32,
      (Ptr{Cvoid}, UInt32, Ptr{Ptr{UInt16}}),
      operation, timeoutMs, resultDocument)
# operation : HCS_OPERATION -> Ptr{Cvoid}
# timeoutMs : DWORD -> UInt32
# resultDocument : LPWSTR* optional, out -> Ptr{Ptr{UInt16}}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t HcsWaitForOperationResult(
    void* operation,
    uint32_t timeoutMs,
    uint16_t** resultDocument);
]]
local computecore = ffi.load("computecore")
-- computecore.HcsWaitForOperationResult(operation, timeoutMs, resultDocument)
-- operation : HCS_OPERATION
-- timeoutMs : DWORD
-- resultDocument : LPWSTR* optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('computecore.dll');
const HcsWaitForOperationResult = lib.func('__stdcall', 'HcsWaitForOperationResult', 'int32_t', ['void *', 'uint32_t', 'void *']);
// HcsWaitForOperationResult(operation, timeoutMs, resultDocument)
// operation : HCS_OPERATION -> 'void *'
// timeoutMs : DWORD -> 'uint32_t'
// resultDocument : LPWSTR* optional, out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("computecore.dll", {
  HcsWaitForOperationResult: { parameters: ["pointer", "u32", "pointer"], result: "i32" },
});
// lib.symbols.HcsWaitForOperationResult(operation, timeoutMs, resultDocument)
// operation : HCS_OPERATION -> "pointer"
// timeoutMs : DWORD -> "u32"
// resultDocument : LPWSTR* optional, out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t HcsWaitForOperationResult(
    void* operation,
    uint32_t timeoutMs,
    uint16_t** resultDocument);
C, "computecore.dll");
// $ffi->HcsWaitForOperationResult(operation, timeoutMs, resultDocument);
// operation : HCS_OPERATION
// timeoutMs : DWORD
// resultDocument : LPWSTR* optional, 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 Computecore extends StdCallLibrary {
    Computecore INSTANCE = Native.load("computecore", Computecore.class);
    int HcsWaitForOperationResult(
        Pointer operation,   // HCS_OPERATION
        int timeoutMs,   // DWORD
        PointerByReference resultDocument   // LPWSTR* optional, out
    );
}
@[Link("computecore")]
lib Libcomputecore
  fun HcsWaitForOperationResult = HcsWaitForOperationResult(
    operation : Void*,   # HCS_OPERATION
    timeoutMs : UInt32,   # DWORD
    resultDocument : UInt16**   # LPWSTR* optional, out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef HcsWaitForOperationResultNative = Int32 Function(Pointer<Void>, Uint32, Pointer<Pointer<Utf16>>);
typedef HcsWaitForOperationResultDart = int Function(Pointer<Void>, int, Pointer<Pointer<Utf16>>);
final HcsWaitForOperationResult = DynamicLibrary.open('computecore.dll')
    .lookupFunction<HcsWaitForOperationResultNative, HcsWaitForOperationResultDart>('HcsWaitForOperationResult');
// operation : HCS_OPERATION -> Pointer<Void>
// timeoutMs : DWORD -> Uint32
// resultDocument : LPWSTR* optional, out -> Pointer<Pointer<Utf16>>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function HcsWaitForOperationResult(
  operation: THandle;   // HCS_OPERATION
  timeoutMs: DWORD;   // DWORD
  resultDocument: PPWideChar   // LPWSTR* optional, out
): Integer; stdcall;
  external 'computecore.dll' name 'HcsWaitForOperationResult';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "HcsWaitForOperationResult"
  c_HcsWaitForOperationResult :: Ptr () -> Word32 -> Ptr CWString -> IO Int32
-- operation : HCS_OPERATION -> Ptr ()
-- timeoutMs : DWORD -> Word32
-- resultDocument : LPWSTR* optional, out -> Ptr CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let hcswaitforoperationresult =
  foreign "HcsWaitForOperationResult"
    ((ptr void) @-> uint32_t @-> (ptr (ptr uint16_t)) @-> returning int32_t)
(* operation : HCS_OPERATION -> (ptr void) *)
(* timeoutMs : DWORD -> uint32_t *)
(* resultDocument : LPWSTR* optional, out -> (ptr (ptr uint16_t)) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library computecore (t "computecore.dll"))
(cffi:use-foreign-library computecore)

(cffi:defcfun ("HcsWaitForOperationResult" hcs-wait-for-operation-result :convention :stdcall) :int32
  (operation :pointer)   ; HCS_OPERATION
  (timeout-ms :uint32)   ; DWORD
  (result-document :pointer))   ; LPWSTR* optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $HcsWaitForOperationResult = Win32::API::More->new('computecore',
    'int HcsWaitForOperationResult(HANDLE operation, DWORD timeoutMs, LPVOID resultDocument)');
# my $ret = $HcsWaitForOperationResult->Call($operation, $timeoutMs, $resultDocument);
# operation : HCS_OPERATION -> HANDLE
# timeoutMs : DWORD -> DWORD
# resultDocument : LPWSTR* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。