ホーム › System.HostComputeSystem › HcsWaitForOperationResultAndProcessInfo
HcsWaitForOperationResultAndProcessInfo
関数HCS操作の完了を待ち結果とプロセス情報を取得する。
シグネチャ
// computecore.dll
#include <windows.h>
HRESULT HcsWaitForOperationResultAndProcessInfo(
HCS_OPERATION operation,
DWORD timeoutMs,
HCS_PROCESS_INFORMATION* processInformation, // optional
LPWSTR* resultDocument // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| operation | HCS_OPERATION | in | 完了を待機する対象のHCS操作ハンドル。 |
| timeoutMs | DWORD | in | 待機する最大時間をミリ秒で指定する。INFINITEで無制限待機。 |
| processInformation | HCS_PROCESS_INFORMATION* | outoptional | プロセスのstdio等の情報を受け取る構造体へのポインタ。 |
| resultDocument | LPWSTR* | outoptional | 操作結果のJSON文書を受け取るポインタ。要解放。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// computecore.dll
#include <windows.h>
HRESULT HcsWaitForOperationResultAndProcessInfo(
HCS_OPERATION operation,
DWORD timeoutMs,
HCS_PROCESS_INFORMATION* processInformation, // optional
LPWSTR* resultDocument // optional
);[DllImport("computecore.dll", ExactSpelling = true)]
static extern int HcsWaitForOperationResultAndProcessInfo(
IntPtr operation, // HCS_OPERATION
uint timeoutMs, // DWORD
IntPtr processInformation, // HCS_PROCESS_INFORMATION* optional, out
IntPtr resultDocument // LPWSTR* optional, out
);<DllImport("computecore.dll", ExactSpelling:=True)>
Public Shared Function HcsWaitForOperationResultAndProcessInfo(
operation As IntPtr, ' HCS_OPERATION
timeoutMs As UInteger, ' DWORD
processInformation As IntPtr, ' HCS_PROCESS_INFORMATION* optional, out
resultDocument As IntPtr ' LPWSTR* optional, out
) As Integer
End Function' operation : HCS_OPERATION
' timeoutMs : DWORD
' processInformation : HCS_PROCESS_INFORMATION* optional, out
' resultDocument : LPWSTR* optional, out
Declare PtrSafe Function HcsWaitForOperationResultAndProcessInfo Lib "computecore" ( _
ByVal operation As LongPtr, _
ByVal timeoutMs As Long, _
ByVal processInformation As LongPtr, _
ByVal resultDocument As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
HcsWaitForOperationResultAndProcessInfo = ctypes.windll.computecore.HcsWaitForOperationResultAndProcessInfo
HcsWaitForOperationResultAndProcessInfo.restype = ctypes.c_int
HcsWaitForOperationResultAndProcessInfo.argtypes = [
wintypes.HANDLE, # operation : HCS_OPERATION
wintypes.DWORD, # timeoutMs : DWORD
ctypes.c_void_p, # processInformation : HCS_PROCESS_INFORMATION* optional, out
ctypes.c_void_p, # resultDocument : LPWSTR* optional, out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('computecore.dll')
HcsWaitForOperationResultAndProcessInfo = Fiddle::Function.new(
lib['HcsWaitForOperationResultAndProcessInfo'],
[
Fiddle::TYPE_VOIDP, # operation : HCS_OPERATION
-Fiddle::TYPE_INT, # timeoutMs : DWORD
Fiddle::TYPE_VOIDP, # processInformation : HCS_PROCESS_INFORMATION* optional, out
Fiddle::TYPE_VOIDP, # resultDocument : LPWSTR* optional, out
],
Fiddle::TYPE_INT)#[link(name = "computecore")]
extern "system" {
fn HcsWaitForOperationResultAndProcessInfo(
operation: *mut core::ffi::c_void, // HCS_OPERATION
timeoutMs: u32, // DWORD
processInformation: *mut HCS_PROCESS_INFORMATION, // HCS_PROCESS_INFORMATION* optional, out
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 HcsWaitForOperationResultAndProcessInfo(IntPtr operation, uint timeoutMs, IntPtr processInformation, IntPtr resultDocument);
"@
$api = Add-Type -MemberDefinition $sig -Name 'computecore_HcsWaitForOperationResultAndProcessInfo' -Namespace Win32 -PassThru
# $api::HcsWaitForOperationResultAndProcessInfo(operation, timeoutMs, processInformation, resultDocument)#uselib "computecore.dll"
#func global HcsWaitForOperationResultAndProcessInfo "HcsWaitForOperationResultAndProcessInfo" sptr, sptr, sptr, sptr
; HcsWaitForOperationResultAndProcessInfo operation, timeoutMs, varptr(processInformation), varptr(resultDocument) ; 戻り値は stat
; operation : HCS_OPERATION -> "sptr"
; timeoutMs : DWORD -> "sptr"
; processInformation : HCS_PROCESS_INFORMATION* optional, out -> "sptr"
; resultDocument : LPWSTR* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "computecore.dll" #cfunc global HcsWaitForOperationResultAndProcessInfo "HcsWaitForOperationResultAndProcessInfo" sptr, int, var, var ; res = HcsWaitForOperationResultAndProcessInfo(operation, timeoutMs, processInformation, resultDocument) ; operation : HCS_OPERATION -> "sptr" ; timeoutMs : DWORD -> "int" ; processInformation : HCS_PROCESS_INFORMATION* optional, out -> "var" ; resultDocument : LPWSTR* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "computecore.dll" #cfunc global HcsWaitForOperationResultAndProcessInfo "HcsWaitForOperationResultAndProcessInfo" sptr, int, sptr, sptr ; res = HcsWaitForOperationResultAndProcessInfo(operation, timeoutMs, varptr(processInformation), varptr(resultDocument)) ; operation : HCS_OPERATION -> "sptr" ; timeoutMs : DWORD -> "int" ; processInformation : HCS_PROCESS_INFORMATION* optional, out -> "sptr" ; resultDocument : LPWSTR* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT HcsWaitForOperationResultAndProcessInfo(HCS_OPERATION operation, DWORD timeoutMs, HCS_PROCESS_INFORMATION* processInformation, LPWSTR* resultDocument) #uselib "computecore.dll" #cfunc global HcsWaitForOperationResultAndProcessInfo "HcsWaitForOperationResultAndProcessInfo" intptr, int, var, var ; res = HcsWaitForOperationResultAndProcessInfo(operation, timeoutMs, processInformation, resultDocument) ; operation : HCS_OPERATION -> "intptr" ; timeoutMs : DWORD -> "int" ; processInformation : HCS_PROCESS_INFORMATION* optional, out -> "var" ; resultDocument : LPWSTR* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT HcsWaitForOperationResultAndProcessInfo(HCS_OPERATION operation, DWORD timeoutMs, HCS_PROCESS_INFORMATION* processInformation, LPWSTR* resultDocument) #uselib "computecore.dll" #cfunc global HcsWaitForOperationResultAndProcessInfo "HcsWaitForOperationResultAndProcessInfo" intptr, int, intptr, intptr ; res = HcsWaitForOperationResultAndProcessInfo(operation, timeoutMs, varptr(processInformation), varptr(resultDocument)) ; operation : HCS_OPERATION -> "intptr" ; timeoutMs : DWORD -> "int" ; processInformation : HCS_PROCESS_INFORMATION* optional, out -> "intptr" ; resultDocument : LPWSTR* optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
computecore = windows.NewLazySystemDLL("computecore.dll")
procHcsWaitForOperationResultAndProcessInfo = computecore.NewProc("HcsWaitForOperationResultAndProcessInfo")
)
// operation (HCS_OPERATION), timeoutMs (DWORD), processInformation (HCS_PROCESS_INFORMATION* optional, out), resultDocument (LPWSTR* optional, out)
r1, _, err := procHcsWaitForOperationResultAndProcessInfo.Call(
uintptr(operation),
uintptr(timeoutMs),
uintptr(processInformation),
uintptr(resultDocument),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction HcsWaitForOperationResultAndProcessInfo(
operation: THandle; // HCS_OPERATION
timeoutMs: DWORD; // DWORD
processInformation: Pointer; // HCS_PROCESS_INFORMATION* optional, out
resultDocument: PPWideChar // LPWSTR* optional, out
): Integer; stdcall;
external 'computecore.dll' name 'HcsWaitForOperationResultAndProcessInfo';result := DllCall("computecore\HcsWaitForOperationResultAndProcessInfo"
, "Ptr", operation ; HCS_OPERATION
, "UInt", timeoutMs ; DWORD
, "Ptr", processInformation ; HCS_PROCESS_INFORMATION* optional, out
, "Ptr", resultDocument ; LPWSTR* optional, out
, "Int") ; return: HRESULT●HcsWaitForOperationResultAndProcessInfo(operation, timeoutMs, processInformation, resultDocument) = DLL("computecore.dll", "int HcsWaitForOperationResultAndProcessInfo(void*, dword, void*, void*)")
# 呼び出し: HcsWaitForOperationResultAndProcessInfo(operation, timeoutMs, processInformation, resultDocument)
# operation : HCS_OPERATION -> "void*"
# timeoutMs : DWORD -> "dword"
# processInformation : HCS_PROCESS_INFORMATION* optional, out -> "void*"
# resultDocument : LPWSTR* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "computecore" fn HcsWaitForOperationResultAndProcessInfo(
operation: ?*anyopaque, // HCS_OPERATION
timeoutMs: u32, // DWORD
processInformation: [*c]HCS_PROCESS_INFORMATION, // HCS_PROCESS_INFORMATION* optional, out
resultDocument: [*c][*c]u16 // LPWSTR* optional, out
) callconv(std.os.windows.WINAPI) i32;proc HcsWaitForOperationResultAndProcessInfo(
operation: pointer, # HCS_OPERATION
timeoutMs: uint32, # DWORD
processInformation: ptr HCS_PROCESS_INFORMATION, # HCS_PROCESS_INFORMATION* optional, out
resultDocument: ptr WideCString # LPWSTR* optional, out
): int32 {.importc: "HcsWaitForOperationResultAndProcessInfo", stdcall, dynlib: "computecore.dll".}pragma(lib, "computecore");
extern(Windows)
int HcsWaitForOperationResultAndProcessInfo(
void* operation, // HCS_OPERATION
uint timeoutMs, // DWORD
HCS_PROCESS_INFORMATION* processInformation, // HCS_PROCESS_INFORMATION* optional, out
wchar** resultDocument // LPWSTR* optional, out
);ccall((:HcsWaitForOperationResultAndProcessInfo, "computecore.dll"), stdcall, Int32,
(Ptr{Cvoid}, UInt32, Ptr{HCS_PROCESS_INFORMATION}, Ptr{Ptr{UInt16}}),
operation, timeoutMs, processInformation, resultDocument)
# operation : HCS_OPERATION -> Ptr{Cvoid}
# timeoutMs : DWORD -> UInt32
# processInformation : HCS_PROCESS_INFORMATION* optional, out -> Ptr{HCS_PROCESS_INFORMATION}
# resultDocument : LPWSTR* optional, out -> Ptr{Ptr{UInt16}}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t HcsWaitForOperationResultAndProcessInfo(
void* operation,
uint32_t timeoutMs,
void* processInformation,
uint16_t** resultDocument);
]]
local computecore = ffi.load("computecore")
-- computecore.HcsWaitForOperationResultAndProcessInfo(operation, timeoutMs, processInformation, resultDocument)
-- operation : HCS_OPERATION
-- timeoutMs : DWORD
-- processInformation : HCS_PROCESS_INFORMATION* optional, out
-- resultDocument : LPWSTR* optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('computecore.dll');
const HcsWaitForOperationResultAndProcessInfo = lib.func('__stdcall', 'HcsWaitForOperationResultAndProcessInfo', 'int32_t', ['void *', 'uint32_t', 'void *', 'void *']);
// HcsWaitForOperationResultAndProcessInfo(operation, timeoutMs, processInformation, resultDocument)
// operation : HCS_OPERATION -> 'void *'
// timeoutMs : DWORD -> 'uint32_t'
// processInformation : HCS_PROCESS_INFORMATION* optional, out -> 'void *'
// resultDocument : LPWSTR* optional, out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("computecore.dll", {
HcsWaitForOperationResultAndProcessInfo: { parameters: ["pointer", "u32", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.HcsWaitForOperationResultAndProcessInfo(operation, timeoutMs, processInformation, resultDocument)
// operation : HCS_OPERATION -> "pointer"
// timeoutMs : DWORD -> "u32"
// processInformation : HCS_PROCESS_INFORMATION* optional, out -> "pointer"
// resultDocument : LPWSTR* optional, out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t HcsWaitForOperationResultAndProcessInfo(
void* operation,
uint32_t timeoutMs,
void* processInformation,
uint16_t** resultDocument);
C, "computecore.dll");
// $ffi->HcsWaitForOperationResultAndProcessInfo(operation, timeoutMs, processInformation, resultDocument);
// operation : HCS_OPERATION
// timeoutMs : DWORD
// processInformation : HCS_PROCESS_INFORMATION* optional, out
// 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 HcsWaitForOperationResultAndProcessInfo(
Pointer operation, // HCS_OPERATION
int timeoutMs, // DWORD
Pointer processInformation, // HCS_PROCESS_INFORMATION* optional, out
PointerByReference resultDocument // LPWSTR* optional, out
);
}@[Link("computecore")]
lib Libcomputecore
fun HcsWaitForOperationResultAndProcessInfo = HcsWaitForOperationResultAndProcessInfo(
operation : Void*, # HCS_OPERATION
timeoutMs : UInt32, # DWORD
processInformation : HCS_PROCESS_INFORMATION*, # HCS_PROCESS_INFORMATION* optional, out
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 HcsWaitForOperationResultAndProcessInfoNative = Int32 Function(Pointer<Void>, Uint32, Pointer<Void>, Pointer<Pointer<Utf16>>);
typedef HcsWaitForOperationResultAndProcessInfoDart = int Function(Pointer<Void>, int, Pointer<Void>, Pointer<Pointer<Utf16>>);
final HcsWaitForOperationResultAndProcessInfo = DynamicLibrary.open('computecore.dll')
.lookupFunction<HcsWaitForOperationResultAndProcessInfoNative, HcsWaitForOperationResultAndProcessInfoDart>('HcsWaitForOperationResultAndProcessInfo');
// operation : HCS_OPERATION -> Pointer<Void>
// timeoutMs : DWORD -> Uint32
// processInformation : HCS_PROCESS_INFORMATION* optional, out -> Pointer<Void>
// resultDocument : LPWSTR* optional, out -> Pointer<Pointer<Utf16>>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function HcsWaitForOperationResultAndProcessInfo(
operation: THandle; // HCS_OPERATION
timeoutMs: DWORD; // DWORD
processInformation: Pointer; // HCS_PROCESS_INFORMATION* optional, out
resultDocument: PPWideChar // LPWSTR* optional, out
): Integer; stdcall;
external 'computecore.dll' name 'HcsWaitForOperationResultAndProcessInfo';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "HcsWaitForOperationResultAndProcessInfo"
c_HcsWaitForOperationResultAndProcessInfo :: Ptr () -> Word32 -> Ptr () -> Ptr CWString -> IO Int32
-- operation : HCS_OPERATION -> Ptr ()
-- timeoutMs : DWORD -> Word32
-- processInformation : HCS_PROCESS_INFORMATION* optional, out -> Ptr ()
-- resultDocument : LPWSTR* optional, out -> Ptr CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let hcswaitforoperationresultandprocessinfo =
foreign "HcsWaitForOperationResultAndProcessInfo"
((ptr void) @-> uint32_t @-> (ptr void) @-> (ptr (ptr uint16_t)) @-> returning int32_t)
(* operation : HCS_OPERATION -> (ptr void) *)
(* timeoutMs : DWORD -> uint32_t *)
(* processInformation : HCS_PROCESS_INFORMATION* optional, out -> (ptr void) *)
(* 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 ("HcsWaitForOperationResultAndProcessInfo" hcs-wait-for-operation-result-and-process-info :convention :stdcall) :int32
(operation :pointer) ; HCS_OPERATION
(timeout-ms :uint32) ; DWORD
(process-information :pointer) ; HCS_PROCESS_INFORMATION* optional, out
(result-document :pointer)) ; LPWSTR* optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $HcsWaitForOperationResultAndProcessInfo = Win32::API::More->new('computecore',
'int HcsWaitForOperationResultAndProcessInfo(HANDLE operation, DWORD timeoutMs, LPVOID processInformation, LPVOID resultDocument)');
# my $ret = $HcsWaitForOperationResultAndProcessInfo->Call($operation, $timeoutMs, $processInformation, $resultDocument);
# operation : HCS_OPERATION -> HANDLE
# timeoutMs : DWORD -> DWORD
# processInformation : HCS_PROCESS_INFORMATION* optional, out -> LPVOID
# resultDocument : LPWSTR* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。