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

HcsSaveComputeSystem

関数
コンピュートシステムの状態を保存する。
DLLcomputecore.dll呼出規約winapi

シグネチャ

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

HRESULT HcsSaveComputeSystem(
    HCS_SYSTEM computeSystem,
    HCS_OPERATION operation,
    LPCWSTR options   // optional
);

パラメーター

名前方向説明
computeSystemHCS_SYSTEMin状態を保存する対象の計算システムハンドル。
operationHCS_OPERATIONin処理結果を受け取る非同期HCS操作のハンドル。
optionsLPCWSTRinoptional保存方法を記述したJSON形式のオプション文字列。NULL可。

戻り値の型: HRESULT

各言語での呼び出し定義

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

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

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

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

var (
	computecore = windows.NewLazySystemDLL("computecore.dll")
	procHcsSaveComputeSystem = computecore.NewProc("HcsSaveComputeSystem")
)

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

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

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

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

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

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