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

HcsCreateComputeSystemInNamespace

関数
指定名前空間内にコンピュートシステムを作成する。
DLLcomputecore.dll呼出規約winapi

シグネチャ

// 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
);

パラメーター

名前方向
idNamespaceLPCWSTRin
idLPCWSTRin
configurationLPCWSTRin
operationHCS_OPERATIONin
optionsHCS_CREATE_OPTIONS*inoptional
computeSystemHCS_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, 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, int, 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 -> "int"
; computeSystem : HCS_SYSTEM* out -> "sptr"
; 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, int, 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 -> "int"
; computeSystem : HCS_SYSTEM* out -> "intptr"
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   // HRESULT
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';
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)。