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