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

HcsModifyComputeSystem

関数
コンピュートシステムの構成を変更する。
DLLcomputecore.dll呼出規約winapi

シグネチャ

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

HRESULT HcsModifyComputeSystem(
    HCS_SYSTEM computeSystem,
    HCS_OPERATION operation,
    LPCWSTR configuration,
    HANDLE identity   // optional
);

パラメーター

名前方向説明
computeSystemHCS_SYSTEMin設定を変更する対象の計算システムハンドル。
operationHCS_OPERATIONin処理結果を受け取る非同期HCS操作のハンドル。
configurationLPCWSTRin変更内容を記述したJSON形式の構成文字列。
identityHANDLEinoptional変更操作に用いる権限を表すトークンハンドル。不要ならNULL可。

戻り値の型: HRESULT

各言語での呼び出し定義

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

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

HcsModifyComputeSystem = ctypes.windll.computecore.HcsModifyComputeSystem
HcsModifyComputeSystem.restype = ctypes.c_int
HcsModifyComputeSystem.argtypes = [
    wintypes.HANDLE,  # computeSystem : HCS_SYSTEM
    wintypes.HANDLE,  # operation : HCS_OPERATION
    wintypes.LPCWSTR,  # configuration : LPCWSTR
    wintypes.HANDLE,  # identity : HANDLE optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('computecore.dll')
HcsModifyComputeSystem = Fiddle::Function.new(
  lib['HcsModifyComputeSystem'],
  [
    Fiddle::TYPE_VOIDP,  # computeSystem : HCS_SYSTEM
    Fiddle::TYPE_VOIDP,  # operation : HCS_OPERATION
    Fiddle::TYPE_VOIDP,  # configuration : LPCWSTR
    Fiddle::TYPE_VOIDP,  # identity : HANDLE optional
  ],
  Fiddle::TYPE_INT)
#[link(name = "computecore")]
extern "system" {
    fn HcsModifyComputeSystem(
        computeSystem: *mut core::ffi::c_void,  // HCS_SYSTEM
        operation: *mut core::ffi::c_void,  // HCS_OPERATION
        configuration: *const u16,  // LPCWSTR
        identity: *mut core::ffi::c_void  // HANDLE optional
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("computecore.dll")]
public static extern int HcsModifyComputeSystem(IntPtr computeSystem, IntPtr operation, [MarshalAs(UnmanagedType.LPWStr)] string configuration, IntPtr identity);
"@
$api = Add-Type -MemberDefinition $sig -Name 'computecore_HcsModifyComputeSystem' -Namespace Win32 -PassThru
# $api::HcsModifyComputeSystem(computeSystem, operation, configuration, identity)
#uselib "computecore.dll"
#func global HcsModifyComputeSystem "HcsModifyComputeSystem" sptr, sptr, sptr, sptr
; HcsModifyComputeSystem computeSystem, operation, configuration, identity   ; 戻り値は stat
; computeSystem : HCS_SYSTEM -> "sptr"
; operation : HCS_OPERATION -> "sptr"
; configuration : LPCWSTR -> "sptr"
; identity : HANDLE optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "computecore.dll"
#cfunc global HcsModifyComputeSystem "HcsModifyComputeSystem" sptr, sptr, wstr, sptr
; res = HcsModifyComputeSystem(computeSystem, operation, configuration, identity)
; computeSystem : HCS_SYSTEM -> "sptr"
; operation : HCS_OPERATION -> "sptr"
; configuration : LPCWSTR -> "wstr"
; identity : HANDLE optional -> "sptr"
; HRESULT HcsModifyComputeSystem(HCS_SYSTEM computeSystem, HCS_OPERATION operation, LPCWSTR configuration, HANDLE identity)
#uselib "computecore.dll"
#cfunc global HcsModifyComputeSystem "HcsModifyComputeSystem" intptr, intptr, wstr, intptr
; res = HcsModifyComputeSystem(computeSystem, operation, configuration, identity)
; computeSystem : HCS_SYSTEM -> "intptr"
; operation : HCS_OPERATION -> "intptr"
; configuration : LPCWSTR -> "wstr"
; identity : HANDLE optional -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	computecore = windows.NewLazySystemDLL("computecore.dll")
	procHcsModifyComputeSystem = computecore.NewProc("HcsModifyComputeSystem")
)

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

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

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

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

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

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