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

HcsGetOperationResultAndProcessInfo

関数
HCS操作の結果とプロセス情報を取得する。
DLLcomputecore.dll呼出規約winapi

シグネチャ

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

HRESULT HcsGetOperationResultAndProcessInfo(
    HCS_OPERATION operation,
    HCS_PROCESS_INFORMATION* processInformation,   // optional
    LPWSTR* resultDocument   // optional
);

パラメーター

名前方向説明
operationHCS_OPERATIONin結果とプロセス情報を取得する対象のHCS操作ハンドル。
processInformationHCS_PROCESS_INFORMATION*outoptionalプロセスのstdio等の情報を受け取る構造体へのポインタ。
resultDocumentLPWSTR*outoptional操作結果のJSON文書を受け取るポインタ。要解放。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT HcsGetOperationResultAndProcessInfo(
    HCS_OPERATION operation,
    HCS_PROCESS_INFORMATION* processInformation,   // optional
    LPWSTR* resultDocument   // optional
);
[DllImport("computecore.dll", ExactSpelling = true)]
static extern int HcsGetOperationResultAndProcessInfo(
    IntPtr operation,   // HCS_OPERATION
    IntPtr processInformation,   // HCS_PROCESS_INFORMATION* optional, out
    IntPtr resultDocument   // LPWSTR* optional, out
);
<DllImport("computecore.dll", ExactSpelling:=True)>
Public Shared Function HcsGetOperationResultAndProcessInfo(
    operation As IntPtr,   ' HCS_OPERATION
    processInformation As IntPtr,   ' HCS_PROCESS_INFORMATION* optional, out
    resultDocument As IntPtr   ' LPWSTR* optional, out
) As Integer
End Function
' operation : HCS_OPERATION
' processInformation : HCS_PROCESS_INFORMATION* optional, out
' resultDocument : LPWSTR* optional, out
Declare PtrSafe Function HcsGetOperationResultAndProcessInfo Lib "computecore" ( _
    ByVal operation As LongPtr, _
    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

HcsGetOperationResultAndProcessInfo = ctypes.windll.computecore.HcsGetOperationResultAndProcessInfo
HcsGetOperationResultAndProcessInfo.restype = ctypes.c_int
HcsGetOperationResultAndProcessInfo.argtypes = [
    wintypes.HANDLE,  # operation : HCS_OPERATION
    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')
HcsGetOperationResultAndProcessInfo = Fiddle::Function.new(
  lib['HcsGetOperationResultAndProcessInfo'],
  [
    Fiddle::TYPE_VOIDP,  # operation : HCS_OPERATION
    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 HcsGetOperationResultAndProcessInfo(
        operation: *mut core::ffi::c_void,  // HCS_OPERATION
        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 HcsGetOperationResultAndProcessInfo(IntPtr operation, IntPtr processInformation, IntPtr resultDocument);
"@
$api = Add-Type -MemberDefinition $sig -Name 'computecore_HcsGetOperationResultAndProcessInfo' -Namespace Win32 -PassThru
# $api::HcsGetOperationResultAndProcessInfo(operation, processInformation, resultDocument)
#uselib "computecore.dll"
#func global HcsGetOperationResultAndProcessInfo "HcsGetOperationResultAndProcessInfo" sptr, sptr, sptr
; HcsGetOperationResultAndProcessInfo operation, varptr(processInformation), varptr(resultDocument)   ; 戻り値は stat
; operation : HCS_OPERATION -> "sptr"
; processInformation : HCS_PROCESS_INFORMATION* optional, out -> "sptr"
; resultDocument : LPWSTR* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "computecore.dll"
#cfunc global HcsGetOperationResultAndProcessInfo "HcsGetOperationResultAndProcessInfo" sptr, var, var
; res = HcsGetOperationResultAndProcessInfo(operation, processInformation, resultDocument)
; operation : HCS_OPERATION -> "sptr"
; processInformation : HCS_PROCESS_INFORMATION* optional, out -> "var"
; resultDocument : LPWSTR* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT HcsGetOperationResultAndProcessInfo(HCS_OPERATION operation, HCS_PROCESS_INFORMATION* processInformation, LPWSTR* resultDocument)
#uselib "computecore.dll"
#cfunc global HcsGetOperationResultAndProcessInfo "HcsGetOperationResultAndProcessInfo" intptr, var, var
; res = HcsGetOperationResultAndProcessInfo(operation, processInformation, resultDocument)
; operation : HCS_OPERATION -> "intptr"
; processInformation : HCS_PROCESS_INFORMATION* optional, out -> "var"
; resultDocument : LPWSTR* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	computecore = windows.NewLazySystemDLL("computecore.dll")
	procHcsGetOperationResultAndProcessInfo = computecore.NewProc("HcsGetOperationResultAndProcessInfo")
)

// operation (HCS_OPERATION), processInformation (HCS_PROCESS_INFORMATION* optional, out), resultDocument (LPWSTR* optional, out)
r1, _, err := procHcsGetOperationResultAndProcessInfo.Call(
	uintptr(operation),
	uintptr(processInformation),
	uintptr(resultDocument),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function HcsGetOperationResultAndProcessInfo(
  operation: THandle;   // HCS_OPERATION
  processInformation: Pointer;   // HCS_PROCESS_INFORMATION* optional, out
  resultDocument: PPWideChar   // LPWSTR* optional, out
): Integer; stdcall;
  external 'computecore.dll' name 'HcsGetOperationResultAndProcessInfo';
result := DllCall("computecore\HcsGetOperationResultAndProcessInfo"
    , "Ptr", operation   ; HCS_OPERATION
    , "Ptr", processInformation   ; HCS_PROCESS_INFORMATION* optional, out
    , "Ptr", resultDocument   ; LPWSTR* optional, out
    , "Int")   ; return: HRESULT
●HcsGetOperationResultAndProcessInfo(operation, processInformation, resultDocument) = DLL("computecore.dll", "int HcsGetOperationResultAndProcessInfo(void*, void*, void*)")
# 呼び出し: HcsGetOperationResultAndProcessInfo(operation, processInformation, resultDocument)
# operation : HCS_OPERATION -> "void*"
# 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 HcsGetOperationResultAndProcessInfo(
    operation: ?*anyopaque, // HCS_OPERATION
    processInformation: [*c]HCS_PROCESS_INFORMATION, // HCS_PROCESS_INFORMATION* optional, out
    resultDocument: [*c][*c]u16 // LPWSTR* optional, out
) callconv(std.os.windows.WINAPI) i32;
proc HcsGetOperationResultAndProcessInfo(
    operation: pointer,  # HCS_OPERATION
    processInformation: ptr HCS_PROCESS_INFORMATION,  # HCS_PROCESS_INFORMATION* optional, out
    resultDocument: ptr WideCString  # LPWSTR* optional, out
): int32 {.importc: "HcsGetOperationResultAndProcessInfo", stdcall, dynlib: "computecore.dll".}
pragma(lib, "computecore");
extern(Windows)
int HcsGetOperationResultAndProcessInfo(
    void* operation,   // HCS_OPERATION
    HCS_PROCESS_INFORMATION* processInformation,   // HCS_PROCESS_INFORMATION* optional, out
    wchar** resultDocument   // LPWSTR* optional, out
);
ccall((:HcsGetOperationResultAndProcessInfo, "computecore.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Ptr{HCS_PROCESS_INFORMATION}, Ptr{Ptr{UInt16}}),
      operation, processInformation, resultDocument)
# operation : HCS_OPERATION -> Ptr{Cvoid}
# 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 HcsGetOperationResultAndProcessInfo(
    void* operation,
    void* processInformation,
    uint16_t** resultDocument);
]]
local computecore = ffi.load("computecore")
-- computecore.HcsGetOperationResultAndProcessInfo(operation, processInformation, resultDocument)
-- operation : HCS_OPERATION
-- 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 HcsGetOperationResultAndProcessInfo = lib.func('__stdcall', 'HcsGetOperationResultAndProcessInfo', 'int32_t', ['void *', 'void *', 'void *']);
// HcsGetOperationResultAndProcessInfo(operation, processInformation, resultDocument)
// operation : HCS_OPERATION -> 'void *'
// processInformation : HCS_PROCESS_INFORMATION* optional, out -> 'void *'
// resultDocument : LPWSTR* optional, out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("computecore.dll", {
  HcsGetOperationResultAndProcessInfo: { parameters: ["pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.HcsGetOperationResultAndProcessInfo(operation, processInformation, resultDocument)
// operation : HCS_OPERATION -> "pointer"
// 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 HcsGetOperationResultAndProcessInfo(
    void* operation,
    void* processInformation,
    uint16_t** resultDocument);
C, "computecore.dll");
// $ffi->HcsGetOperationResultAndProcessInfo(operation, processInformation, resultDocument);
// operation : HCS_OPERATION
// 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 HcsGetOperationResultAndProcessInfo(
        Pointer operation,   // HCS_OPERATION
        Pointer processInformation,   // HCS_PROCESS_INFORMATION* optional, out
        PointerByReference resultDocument   // LPWSTR* optional, out
    );
}
@[Link("computecore")]
lib Libcomputecore
  fun HcsGetOperationResultAndProcessInfo = HcsGetOperationResultAndProcessInfo(
    operation : Void*,   # HCS_OPERATION
    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 HcsGetOperationResultAndProcessInfoNative = Int32 Function(Pointer<Void>, Pointer<Void>, Pointer<Pointer<Utf16>>);
typedef HcsGetOperationResultAndProcessInfoDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Pointer<Utf16>>);
final HcsGetOperationResultAndProcessInfo = DynamicLibrary.open('computecore.dll')
    .lookupFunction<HcsGetOperationResultAndProcessInfoNative, HcsGetOperationResultAndProcessInfoDart>('HcsGetOperationResultAndProcessInfo');
// operation : HCS_OPERATION -> Pointer<Void>
// processInformation : HCS_PROCESS_INFORMATION* optional, out -> Pointer<Void>
// resultDocument : LPWSTR* optional, out -> Pointer<Pointer<Utf16>>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function HcsGetOperationResultAndProcessInfo(
  operation: THandle;   // HCS_OPERATION
  processInformation: Pointer;   // HCS_PROCESS_INFORMATION* optional, out
  resultDocument: PPWideChar   // LPWSTR* optional, out
): Integer; stdcall;
  external 'computecore.dll' name 'HcsGetOperationResultAndProcessInfo';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "HcsGetOperationResultAndProcessInfo"
  c_HcsGetOperationResultAndProcessInfo :: Ptr () -> Ptr () -> Ptr CWString -> IO Int32
-- operation : HCS_OPERATION -> Ptr ()
-- 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 hcsgetoperationresultandprocessinfo =
  foreign "HcsGetOperationResultAndProcessInfo"
    ((ptr void) @-> (ptr void) @-> (ptr (ptr uint16_t)) @-> returning int32_t)
(* operation : HCS_OPERATION -> (ptr void) *)
(* 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 ("HcsGetOperationResultAndProcessInfo" hcs-get-operation-result-and-process-info :convention :stdcall) :int32
  (operation :pointer)   ; HCS_OPERATION
  (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 $HcsGetOperationResultAndProcessInfo = Win32::API::More->new('computecore',
    'int HcsGetOperationResultAndProcessInfo(HANDLE operation, LPVOID processInformation, LPVOID resultDocument)');
# my $ret = $HcsGetOperationResultAndProcessInfo->Call($operation, $processInformation, $resultDocument);
# operation : HCS_OPERATION -> HANDLE
# processInformation : HCS_PROCESS_INFORMATION* optional, out -> LPVOID
# resultDocument : LPWSTR* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型