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

HcsCreateComputeSystem

関数
指定構成で新しいコンピュートシステムを作成する。
DLLcomputecore.dll呼出規約winapi

シグネチャ

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

HRESULT HcsCreateComputeSystem(
    LPCWSTR id,
    LPCWSTR configuration,
    HCS_OPERATION operation,
    const SECURITY_DESCRIPTOR* securityDescriptor,   // optional
    HCS_SYSTEM* computeSystem
);

パラメーター

名前方向説明
idLPCWSTRin新規計算システムを識別する一意のID文字列。
configurationLPCWSTRinシステム構成を記述したJSON形式の設定文字列。
operationHCS_OPERATIONin作成処理の結果を受け取る非同期HCS操作のハンドル。
securityDescriptorSECURITY_DESCRIPTOR*inoptionalシステムに適用するセキュリティ記述子へのポインタ。NULL可。
computeSystemHCS_SYSTEM*out生成された計算システムのハンドルを受け取るポインタ。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT HcsCreateComputeSystem(
    LPCWSTR id,
    LPCWSTR configuration,
    HCS_OPERATION operation,
    const SECURITY_DESCRIPTOR* securityDescriptor,   // optional
    HCS_SYSTEM* computeSystem
);
[DllImport("computecore.dll", ExactSpelling = true)]
static extern int HcsCreateComputeSystem(
    [MarshalAs(UnmanagedType.LPWStr)] string id,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string configuration,   // LPCWSTR
    IntPtr operation,   // HCS_OPERATION
    IntPtr securityDescriptor,   // SECURITY_DESCRIPTOR* optional
    IntPtr computeSystem   // HCS_SYSTEM* out
);
<DllImport("computecore.dll", ExactSpelling:=True)>
Public Shared Function HcsCreateComputeSystem(
    <MarshalAs(UnmanagedType.LPWStr)> id As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> configuration As String,   ' LPCWSTR
    operation As IntPtr,   ' HCS_OPERATION
    securityDescriptor As IntPtr,   ' SECURITY_DESCRIPTOR* optional
    computeSystem As IntPtr   ' HCS_SYSTEM* out
) As Integer
End Function
' id : LPCWSTR
' configuration : LPCWSTR
' operation : HCS_OPERATION
' securityDescriptor : SECURITY_DESCRIPTOR* optional
' computeSystem : HCS_SYSTEM* out
Declare PtrSafe Function HcsCreateComputeSystem Lib "computecore" ( _
    ByVal id As LongPtr, _
    ByVal configuration As LongPtr, _
    ByVal operation As LongPtr, _
    ByVal securityDescriptor As LongPtr, _
    ByVal computeSystem As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

HcsCreateComputeSystem = ctypes.windll.computecore.HcsCreateComputeSystem
HcsCreateComputeSystem.restype = ctypes.c_int
HcsCreateComputeSystem.argtypes = [
    wintypes.LPCWSTR,  # id : LPCWSTR
    wintypes.LPCWSTR,  # configuration : LPCWSTR
    wintypes.HANDLE,  # operation : HCS_OPERATION
    ctypes.c_void_p,  # securityDescriptor : SECURITY_DESCRIPTOR* optional
    ctypes.c_void_p,  # computeSystem : HCS_SYSTEM* out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	computecore = windows.NewLazySystemDLL("computecore.dll")
	procHcsCreateComputeSystem = computecore.NewProc("HcsCreateComputeSystem")
)

// id (LPCWSTR), configuration (LPCWSTR), operation (HCS_OPERATION), securityDescriptor (SECURITY_DESCRIPTOR* optional), computeSystem (HCS_SYSTEM* out)
r1, _, err := procHcsCreateComputeSystem.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(id))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(configuration))),
	uintptr(operation),
	uintptr(securityDescriptor),
	uintptr(computeSystem),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function HcsCreateComputeSystem(
  id: PWideChar;   // LPCWSTR
  configuration: PWideChar;   // LPCWSTR
  operation: THandle;   // HCS_OPERATION
  securityDescriptor: Pointer;   // SECURITY_DESCRIPTOR* optional
  computeSystem: Pointer   // HCS_SYSTEM* out
): Integer; stdcall;
  external 'computecore.dll' name 'HcsCreateComputeSystem';
result := DllCall("computecore\HcsCreateComputeSystem"
    , "WStr", id   ; LPCWSTR
    , "WStr", configuration   ; LPCWSTR
    , "Ptr", operation   ; HCS_OPERATION
    , "Ptr", securityDescriptor   ; SECURITY_DESCRIPTOR* optional
    , "Ptr", computeSystem   ; HCS_SYSTEM* out
    , "Int")   ; return: HRESULT
●HcsCreateComputeSystem(id, configuration, operation, securityDescriptor, computeSystem) = DLL("computecore.dll", "int HcsCreateComputeSystem(char*, char*, void*, void*, void*)")
# 呼び出し: HcsCreateComputeSystem(id, configuration, operation, securityDescriptor, computeSystem)
# id : LPCWSTR -> "char*"
# configuration : LPCWSTR -> "char*"
# operation : HCS_OPERATION -> "void*"
# securityDescriptor : SECURITY_DESCRIPTOR* optional -> "void*"
# computeSystem : HCS_SYSTEM* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

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

typedef HcsCreateComputeSystemNative = Int32 Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Void>, Pointer<Void>, Pointer<Void>);
typedef HcsCreateComputeSystemDart = int Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Void>, Pointer<Void>, Pointer<Void>);
final HcsCreateComputeSystem = DynamicLibrary.open('computecore.dll')
    .lookupFunction<HcsCreateComputeSystemNative, HcsCreateComputeSystemDart>('HcsCreateComputeSystem');
// id : LPCWSTR -> Pointer<Utf16>
// configuration : LPCWSTR -> Pointer<Utf16>
// operation : HCS_OPERATION -> Pointer<Void>
// securityDescriptor : SECURITY_DESCRIPTOR* optional -> Pointer<Void>
// computeSystem : HCS_SYSTEM* out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function HcsCreateComputeSystem(
  id: PWideChar;   // LPCWSTR
  configuration: PWideChar;   // LPCWSTR
  operation: THandle;   // HCS_OPERATION
  securityDescriptor: Pointer;   // SECURITY_DESCRIPTOR* optional
  computeSystem: Pointer   // HCS_SYSTEM* out
): Integer; stdcall;
  external 'computecore.dll' name 'HcsCreateComputeSystem';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "HcsCreateComputeSystem"
  c_HcsCreateComputeSystem :: CWString -> CWString -> Ptr () -> Ptr () -> Ptr () -> IO Int32
-- id : LPCWSTR -> CWString
-- configuration : LPCWSTR -> CWString
-- operation : HCS_OPERATION -> Ptr ()
-- securityDescriptor : SECURITY_DESCRIPTOR* optional -> Ptr ()
-- computeSystem : HCS_SYSTEM* out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let hcscreatecomputesystem =
  foreign "HcsCreateComputeSystem"
    ((ptr uint16_t) @-> (ptr uint16_t) @-> (ptr void) @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* id : LPCWSTR -> (ptr uint16_t) *)
(* configuration : LPCWSTR -> (ptr uint16_t) *)
(* operation : HCS_OPERATION -> (ptr void) *)
(* securityDescriptor : SECURITY_DESCRIPTOR* optional -> (ptr void) *)
(* computeSystem : HCS_SYSTEM* out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library computecore (t "computecore.dll"))
(cffi:use-foreign-library computecore)

(cffi:defcfun ("HcsCreateComputeSystem" hcs-create-compute-system :convention :stdcall) :int32
  (id (:string :encoding :utf-16le))   ; LPCWSTR
  (configuration (:string :encoding :utf-16le))   ; LPCWSTR
  (operation :pointer)   ; HCS_OPERATION
  (security-descriptor :pointer)   ; SECURITY_DESCRIPTOR* optional
  (compute-system :pointer))   ; HCS_SYSTEM* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $HcsCreateComputeSystem = Win32::API::More->new('computecore',
    'int HcsCreateComputeSystem(LPCWSTR id, LPCWSTR configuration, HANDLE operation, LPVOID securityDescriptor, HANDLE computeSystem)');
# my $ret = $HcsCreateComputeSystem->Call($id, $configuration, $operation, $securityDescriptor, $computeSystem);
# id : LPCWSTR -> LPCWSTR
# configuration : LPCWSTR -> LPCWSTR
# operation : HCS_OPERATION -> HANDLE
# securityDescriptor : SECURITY_DESCRIPTOR* optional -> LPVOID
# computeSystem : HCS_SYSTEM* out -> HANDLE
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型