ホーム › System.HostComputeSystem › HcsCreateComputeSystem
HcsCreateComputeSystem
関数指定構成で新しいコンピュートシステムを作成する。
シグネチャ
// computecore.dll
#include <windows.h>
HRESULT HcsCreateComputeSystem(
LPCWSTR id,
LPCWSTR configuration,
HCS_OPERATION operation,
const SECURITY_DESCRIPTOR* securityDescriptor, // optional
HCS_SYSTEM* computeSystem
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| id | LPCWSTR | in |
| configuration | LPCWSTR | in |
| operation | HCS_OPERATION | in |
| securityDescriptor | SECURITY_DESCRIPTOR* | inoptional |
| computeSystem | HCS_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 方式にも切替可。#uselib "computecore.dll" #cfunc global HcsCreateComputeSystem "HcsCreateComputeSystem" wstr, wstr, sptr, sptr, sptr ; res = HcsCreateComputeSystem(id, configuration, operation, varptr(securityDescriptor), computeSystem) ; id : LPCWSTR -> "wstr" ; configuration : LPCWSTR -> "wstr" ; operation : HCS_OPERATION -> "sptr" ; securityDescriptor : SECURITY_DESCRIPTOR* optional -> "sptr" ; computeSystem : HCS_SYSTEM* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは 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 方式にも切替可。; 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, intptr, intptr ; res = HcsCreateComputeSystem(id, configuration, operation, varptr(securityDescriptor), computeSystem) ; id : LPCWSTR -> "wstr" ; configuration : LPCWSTR -> "wstr" ; operation : HCS_OPERATION -> "intptr" ; securityDescriptor : SECURITY_DESCRIPTOR* optional -> "intptr" ; computeSystem : HCS_SYSTEM* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは 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 // HRESULTfunction 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)。