ホーム › System.HostComputeSystem › HcsCreateComputeSystemInNamespace
HcsCreateComputeSystemInNamespace
関数指定名前空間内にコンピュートシステムを作成する。
シグネチャ
// computecore.dll
#include <windows.h>
HRESULT HcsCreateComputeSystemInNamespace(
LPCWSTR idNamespace,
LPCWSTR id,
LPCWSTR configuration,
HCS_OPERATION operation,
const HCS_CREATE_OPTIONS* options, // optional
HCS_SYSTEM* computeSystem
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| idNamespace | LPCWSTR | in | 計算システムを作成する名前空間の識別文字列。 |
| id | LPCWSTR | in | 新規計算システムを識別する一意のID文字列。 |
| configuration | LPCWSTR | in | システム構成を記述したJSON形式の設定文字列。 |
| operation | HCS_OPERATION | in | 作成処理の結果を受け取る非同期HCS操作のハンドル。 |
| options | HCS_CREATE_OPTIONS* | inoptional | 作成時の追加オプションを格納する構造体へのポインタ。NULL可。 |
| computeSystem | HCS_SYSTEM* | out | 生成された計算システムのハンドルを受け取るポインタ。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// computecore.dll
#include <windows.h>
HRESULT HcsCreateComputeSystemInNamespace(
LPCWSTR idNamespace,
LPCWSTR id,
LPCWSTR configuration,
HCS_OPERATION operation,
const HCS_CREATE_OPTIONS* options, // optional
HCS_SYSTEM* computeSystem
);[DllImport("computecore.dll", ExactSpelling = true)]
static extern int HcsCreateComputeSystemInNamespace(
[MarshalAs(UnmanagedType.LPWStr)] string idNamespace, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string id, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string configuration, // LPCWSTR
IntPtr operation, // HCS_OPERATION
IntPtr options, // HCS_CREATE_OPTIONS* optional
IntPtr computeSystem // HCS_SYSTEM* out
);<DllImport("computecore.dll", ExactSpelling:=True)>
Public Shared Function HcsCreateComputeSystemInNamespace(
<MarshalAs(UnmanagedType.LPWStr)> idNamespace As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> id As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> configuration As String, ' LPCWSTR
operation As IntPtr, ' HCS_OPERATION
options As IntPtr, ' HCS_CREATE_OPTIONS* optional
computeSystem As IntPtr ' HCS_SYSTEM* out
) As Integer
End Function' idNamespace : LPCWSTR
' id : LPCWSTR
' configuration : LPCWSTR
' operation : HCS_OPERATION
' options : HCS_CREATE_OPTIONS* optional
' computeSystem : HCS_SYSTEM* out
Declare PtrSafe Function HcsCreateComputeSystemInNamespace Lib "computecore" ( _
ByVal idNamespace As LongPtr, _
ByVal id As LongPtr, _
ByVal configuration As LongPtr, _
ByVal operation As LongPtr, _
ByVal options 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
HcsCreateComputeSystemInNamespace = ctypes.windll.computecore.HcsCreateComputeSystemInNamespace
HcsCreateComputeSystemInNamespace.restype = ctypes.c_int
HcsCreateComputeSystemInNamespace.argtypes = [
wintypes.LPCWSTR, # idNamespace : LPCWSTR
wintypes.LPCWSTR, # id : LPCWSTR
wintypes.LPCWSTR, # configuration : LPCWSTR
wintypes.HANDLE, # operation : HCS_OPERATION
ctypes.c_void_p, # options : HCS_CREATE_OPTIONS* optional
ctypes.c_void_p, # computeSystem : HCS_SYSTEM* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('computecore.dll')
HcsCreateComputeSystemInNamespace = Fiddle::Function.new(
lib['HcsCreateComputeSystemInNamespace'],
[
Fiddle::TYPE_VOIDP, # idNamespace : LPCWSTR
Fiddle::TYPE_VOIDP, # id : LPCWSTR
Fiddle::TYPE_VOIDP, # configuration : LPCWSTR
Fiddle::TYPE_VOIDP, # operation : HCS_OPERATION
Fiddle::TYPE_VOIDP, # options : HCS_CREATE_OPTIONS* optional
Fiddle::TYPE_VOIDP, # computeSystem : HCS_SYSTEM* out
],
Fiddle::TYPE_INT)#[link(name = "computecore")]
extern "system" {
fn HcsCreateComputeSystemInNamespace(
idNamespace: *const u16, // LPCWSTR
id: *const u16, // LPCWSTR
configuration: *const u16, // LPCWSTR
operation: *mut core::ffi::c_void, // HCS_OPERATION
options: *const i32, // HCS_CREATE_OPTIONS* 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 HcsCreateComputeSystemInNamespace([MarshalAs(UnmanagedType.LPWStr)] string idNamespace, [MarshalAs(UnmanagedType.LPWStr)] string id, [MarshalAs(UnmanagedType.LPWStr)] string configuration, IntPtr operation, IntPtr options, IntPtr computeSystem);
"@
$api = Add-Type -MemberDefinition $sig -Name 'computecore_HcsCreateComputeSystemInNamespace' -Namespace Win32 -PassThru
# $api::HcsCreateComputeSystemInNamespace(idNamespace, id, configuration, operation, options, computeSystem)#uselib "computecore.dll"
#func global HcsCreateComputeSystemInNamespace "HcsCreateComputeSystemInNamespace" sptr, sptr, sptr, sptr, sptr, sptr
; HcsCreateComputeSystemInNamespace idNamespace, id, configuration, operation, varptr(options), computeSystem ; 戻り値は stat
; idNamespace : LPCWSTR -> "sptr"
; id : LPCWSTR -> "sptr"
; configuration : LPCWSTR -> "sptr"
; operation : HCS_OPERATION -> "sptr"
; options : HCS_CREATE_OPTIONS* optional -> "sptr"
; computeSystem : HCS_SYSTEM* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "computecore.dll" #cfunc global HcsCreateComputeSystemInNamespace "HcsCreateComputeSystemInNamespace" wstr, wstr, wstr, sptr, var, sptr ; res = HcsCreateComputeSystemInNamespace(idNamespace, id, configuration, operation, options, computeSystem) ; idNamespace : LPCWSTR -> "wstr" ; id : LPCWSTR -> "wstr" ; configuration : LPCWSTR -> "wstr" ; operation : HCS_OPERATION -> "sptr" ; options : HCS_CREATE_OPTIONS* optional -> "var" ; computeSystem : HCS_SYSTEM* out -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "computecore.dll" #cfunc global HcsCreateComputeSystemInNamespace "HcsCreateComputeSystemInNamespace" wstr, wstr, wstr, sptr, sptr, sptr ; res = HcsCreateComputeSystemInNamespace(idNamespace, id, configuration, operation, varptr(options), computeSystem) ; idNamespace : LPCWSTR -> "wstr" ; id : LPCWSTR -> "wstr" ; configuration : LPCWSTR -> "wstr" ; operation : HCS_OPERATION -> "sptr" ; options : HCS_CREATE_OPTIONS* optional -> "sptr" ; computeSystem : HCS_SYSTEM* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT HcsCreateComputeSystemInNamespace(LPCWSTR idNamespace, LPCWSTR id, LPCWSTR configuration, HCS_OPERATION operation, HCS_CREATE_OPTIONS* options, HCS_SYSTEM* computeSystem) #uselib "computecore.dll" #cfunc global HcsCreateComputeSystemInNamespace "HcsCreateComputeSystemInNamespace" wstr, wstr, wstr, intptr, var, intptr ; res = HcsCreateComputeSystemInNamespace(idNamespace, id, configuration, operation, options, computeSystem) ; idNamespace : LPCWSTR -> "wstr" ; id : LPCWSTR -> "wstr" ; configuration : LPCWSTR -> "wstr" ; operation : HCS_OPERATION -> "intptr" ; options : HCS_CREATE_OPTIONS* optional -> "var" ; computeSystem : HCS_SYSTEM* out -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT HcsCreateComputeSystemInNamespace(LPCWSTR idNamespace, LPCWSTR id, LPCWSTR configuration, HCS_OPERATION operation, HCS_CREATE_OPTIONS* options, HCS_SYSTEM* computeSystem) #uselib "computecore.dll" #cfunc global HcsCreateComputeSystemInNamespace "HcsCreateComputeSystemInNamespace" wstr, wstr, wstr, intptr, intptr, intptr ; res = HcsCreateComputeSystemInNamespace(idNamespace, id, configuration, operation, varptr(options), computeSystem) ; idNamespace : LPCWSTR -> "wstr" ; id : LPCWSTR -> "wstr" ; configuration : LPCWSTR -> "wstr" ; operation : HCS_OPERATION -> "intptr" ; options : HCS_CREATE_OPTIONS* optional -> "intptr" ; computeSystem : HCS_SYSTEM* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
computecore = windows.NewLazySystemDLL("computecore.dll")
procHcsCreateComputeSystemInNamespace = computecore.NewProc("HcsCreateComputeSystemInNamespace")
)
// idNamespace (LPCWSTR), id (LPCWSTR), configuration (LPCWSTR), operation (HCS_OPERATION), options (HCS_CREATE_OPTIONS* optional), computeSystem (HCS_SYSTEM* out)
r1, _, err := procHcsCreateComputeSystemInNamespace.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(idNamespace))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(id))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(configuration))),
uintptr(operation),
uintptr(options),
uintptr(computeSystem),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction HcsCreateComputeSystemInNamespace(
idNamespace: PWideChar; // LPCWSTR
id: PWideChar; // LPCWSTR
configuration: PWideChar; // LPCWSTR
operation: THandle; // HCS_OPERATION
options: Pointer; // HCS_CREATE_OPTIONS* optional
computeSystem: Pointer // HCS_SYSTEM* out
): Integer; stdcall;
external 'computecore.dll' name 'HcsCreateComputeSystemInNamespace';result := DllCall("computecore\HcsCreateComputeSystemInNamespace"
, "WStr", idNamespace ; LPCWSTR
, "WStr", id ; LPCWSTR
, "WStr", configuration ; LPCWSTR
, "Ptr", operation ; HCS_OPERATION
, "Ptr", options ; HCS_CREATE_OPTIONS* optional
, "Ptr", computeSystem ; HCS_SYSTEM* out
, "Int") ; return: HRESULT●HcsCreateComputeSystemInNamespace(idNamespace, id, configuration, operation, options, computeSystem) = DLL("computecore.dll", "int HcsCreateComputeSystemInNamespace(char*, char*, char*, void*, void*, void*)")
# 呼び出し: HcsCreateComputeSystemInNamespace(idNamespace, id, configuration, operation, options, computeSystem)
# idNamespace : LPCWSTR -> "char*"
# id : LPCWSTR -> "char*"
# configuration : LPCWSTR -> "char*"
# operation : HCS_OPERATION -> "void*"
# options : HCS_CREATE_OPTIONS* optional -> "void*"
# computeSystem : HCS_SYSTEM* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "computecore" fn HcsCreateComputeSystemInNamespace(
idNamespace: [*c]const u16, // LPCWSTR
id: [*c]const u16, // LPCWSTR
configuration: [*c]const u16, // LPCWSTR
operation: ?*anyopaque, // HCS_OPERATION
options: [*c]i32, // HCS_CREATE_OPTIONS* optional
computeSystem: ?*anyopaque // HCS_SYSTEM* out
) callconv(std.os.windows.WINAPI) i32;proc HcsCreateComputeSystemInNamespace(
idNamespace: WideCString, # LPCWSTR
id: WideCString, # LPCWSTR
configuration: WideCString, # LPCWSTR
operation: pointer, # HCS_OPERATION
options: ptr int32, # HCS_CREATE_OPTIONS* optional
computeSystem: pointer # HCS_SYSTEM* out
): int32 {.importc: "HcsCreateComputeSystemInNamespace", stdcall, dynlib: "computecore.dll".}pragma(lib, "computecore");
extern(Windows)
int HcsCreateComputeSystemInNamespace(
const(wchar)* idNamespace, // LPCWSTR
const(wchar)* id, // LPCWSTR
const(wchar)* configuration, // LPCWSTR
void* operation, // HCS_OPERATION
int* options, // HCS_CREATE_OPTIONS* optional
void* computeSystem // HCS_SYSTEM* out
);ccall((:HcsCreateComputeSystemInNamespace, "computecore.dll"), stdcall, Int32,
(Cwstring, Cwstring, Cwstring, Ptr{Cvoid}, Ptr{Int32}, Ptr{Cvoid}),
idNamespace, id, configuration, operation, options, computeSystem)
# idNamespace : LPCWSTR -> Cwstring
# id : LPCWSTR -> Cwstring
# configuration : LPCWSTR -> Cwstring
# operation : HCS_OPERATION -> Ptr{Cvoid}
# options : HCS_CREATE_OPTIONS* optional -> Ptr{Int32}
# computeSystem : HCS_SYSTEM* out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t HcsCreateComputeSystemInNamespace(
const uint16_t* idNamespace,
const uint16_t* id,
const uint16_t* configuration,
void* operation,
int32_t* options,
void* computeSystem);
]]
local computecore = ffi.load("computecore")
-- computecore.HcsCreateComputeSystemInNamespace(idNamespace, id, configuration, operation, options, computeSystem)
-- idNamespace : LPCWSTR
-- id : LPCWSTR
-- configuration : LPCWSTR
-- operation : HCS_OPERATION
-- options : HCS_CREATE_OPTIONS* optional
-- computeSystem : HCS_SYSTEM* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('computecore.dll');
const HcsCreateComputeSystemInNamespace = lib.func('__stdcall', 'HcsCreateComputeSystemInNamespace', 'int32_t', ['str16', 'str16', 'str16', 'void *', 'int32_t *', 'void *']);
// HcsCreateComputeSystemInNamespace(idNamespace, id, configuration, operation, options, computeSystem)
// idNamespace : LPCWSTR -> 'str16'
// id : LPCWSTR -> 'str16'
// configuration : LPCWSTR -> 'str16'
// operation : HCS_OPERATION -> 'void *'
// options : HCS_CREATE_OPTIONS* optional -> 'int32_t *'
// computeSystem : HCS_SYSTEM* out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("computecore.dll", {
HcsCreateComputeSystemInNamespace: { parameters: ["buffer", "buffer", "buffer", "pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.HcsCreateComputeSystemInNamespace(idNamespace, id, configuration, operation, options, computeSystem)
// idNamespace : LPCWSTR -> "buffer"
// id : LPCWSTR -> "buffer"
// configuration : LPCWSTR -> "buffer"
// operation : HCS_OPERATION -> "pointer"
// options : HCS_CREATE_OPTIONS* optional -> "pointer"
// computeSystem : HCS_SYSTEM* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t HcsCreateComputeSystemInNamespace(
const uint16_t* idNamespace,
const uint16_t* id,
const uint16_t* configuration,
void* operation,
int32_t* options,
void* computeSystem);
C, "computecore.dll");
// $ffi->HcsCreateComputeSystemInNamespace(idNamespace, id, configuration, operation, options, computeSystem);
// idNamespace : LPCWSTR
// id : LPCWSTR
// configuration : LPCWSTR
// operation : HCS_OPERATION
// options : HCS_CREATE_OPTIONS* 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 HcsCreateComputeSystemInNamespace(
WString idNamespace, // LPCWSTR
WString id, // LPCWSTR
WString configuration, // LPCWSTR
Pointer operation, // HCS_OPERATION
IntByReference options, // HCS_CREATE_OPTIONS* optional
Pointer computeSystem // HCS_SYSTEM* out
);
}@[Link("computecore")]
lib Libcomputecore
fun HcsCreateComputeSystemInNamespace = HcsCreateComputeSystemInNamespace(
idNamespace : UInt16*, # LPCWSTR
id : UInt16*, # LPCWSTR
configuration : UInt16*, # LPCWSTR
operation : Void*, # HCS_OPERATION
options : Int32*, # HCS_CREATE_OPTIONS* 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 HcsCreateComputeSystemInNamespaceNative = Int32 Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Void>, Pointer<Int32>, Pointer<Void>);
typedef HcsCreateComputeSystemInNamespaceDart = int Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Void>, Pointer<Int32>, Pointer<Void>);
final HcsCreateComputeSystemInNamespace = DynamicLibrary.open('computecore.dll')
.lookupFunction<HcsCreateComputeSystemInNamespaceNative, HcsCreateComputeSystemInNamespaceDart>('HcsCreateComputeSystemInNamespace');
// idNamespace : LPCWSTR -> Pointer<Utf16>
// id : LPCWSTR -> Pointer<Utf16>
// configuration : LPCWSTR -> Pointer<Utf16>
// operation : HCS_OPERATION -> Pointer<Void>
// options : HCS_CREATE_OPTIONS* optional -> Pointer<Int32>
// computeSystem : HCS_SYSTEM* out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function HcsCreateComputeSystemInNamespace(
idNamespace: PWideChar; // LPCWSTR
id: PWideChar; // LPCWSTR
configuration: PWideChar; // LPCWSTR
operation: THandle; // HCS_OPERATION
options: Pointer; // HCS_CREATE_OPTIONS* optional
computeSystem: Pointer // HCS_SYSTEM* out
): Integer; stdcall;
external 'computecore.dll' name 'HcsCreateComputeSystemInNamespace';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "HcsCreateComputeSystemInNamespace"
c_HcsCreateComputeSystemInNamespace :: CWString -> CWString -> CWString -> Ptr () -> Ptr Int32 -> Ptr () -> IO Int32
-- idNamespace : LPCWSTR -> CWString
-- id : LPCWSTR -> CWString
-- configuration : LPCWSTR -> CWString
-- operation : HCS_OPERATION -> Ptr ()
-- options : HCS_CREATE_OPTIONS* optional -> Ptr Int32
-- computeSystem : HCS_SYSTEM* out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let hcscreatecomputesysteminnamespace =
foreign "HcsCreateComputeSystemInNamespace"
((ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> (ptr void) @-> (ptr int32_t) @-> (ptr void) @-> returning int32_t)
(* idNamespace : LPCWSTR -> (ptr uint16_t) *)
(* id : LPCWSTR -> (ptr uint16_t) *)
(* configuration : LPCWSTR -> (ptr uint16_t) *)
(* operation : HCS_OPERATION -> (ptr void) *)
(* options : HCS_CREATE_OPTIONS* optional -> (ptr int32_t) *)
(* 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 ("HcsCreateComputeSystemInNamespace" hcs-create-compute-system-in-namespace :convention :stdcall) :int32
(id-namespace (:string :encoding :utf-16le)) ; LPCWSTR
(id (:string :encoding :utf-16le)) ; LPCWSTR
(configuration (:string :encoding :utf-16le)) ; LPCWSTR
(operation :pointer) ; HCS_OPERATION
(options :pointer) ; HCS_CREATE_OPTIONS* optional
(compute-system :pointer)) ; HCS_SYSTEM* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $HcsCreateComputeSystemInNamespace = Win32::API::More->new('computecore',
'int HcsCreateComputeSystemInNamespace(LPCWSTR idNamespace, LPCWSTR id, LPCWSTR configuration, HANDLE operation, LPVOID options, HANDLE computeSystem)');
# my $ret = $HcsCreateComputeSystemInNamespace->Call($idNamespace, $id, $configuration, $operation, $options, $computeSystem);
# idNamespace : LPCWSTR -> LPCWSTR
# id : LPCWSTR -> LPCWSTR
# configuration : LPCWSTR -> LPCWSTR
# operation : HCS_OPERATION -> HANDLE
# options : HCS_CREATE_OPTIONS* optional -> LPVOID
# computeSystem : HCS_SYSTEM* out -> HANDLE
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型