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

HcsSetupBaseOSLayer

関数
VHD上にベースOSレイヤーをセットアップする。
DLLcomputestorage.dll呼出規約winapi

シグネチャ

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

HRESULT HcsSetupBaseOSLayer(
    LPCWSTR layerPath,
    HANDLE vhdHandle,
    LPCWSTR options
);

パラメーター

名前方向
layerPathLPCWSTRin
vhdHandleHANDLEin
optionsLPCWSTRin

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT HcsSetupBaseOSLayer(
    LPCWSTR layerPath,
    HANDLE vhdHandle,
    LPCWSTR options
);
[DllImport("computestorage.dll", ExactSpelling = true)]
static extern int HcsSetupBaseOSLayer(
    [MarshalAs(UnmanagedType.LPWStr)] string layerPath,   // LPCWSTR
    IntPtr vhdHandle,   // HANDLE
    [MarshalAs(UnmanagedType.LPWStr)] string options   // LPCWSTR
);
<DllImport("computestorage.dll", ExactSpelling:=True)>
Public Shared Function HcsSetupBaseOSLayer(
    <MarshalAs(UnmanagedType.LPWStr)> layerPath As String,   ' LPCWSTR
    vhdHandle As IntPtr,   ' HANDLE
    <MarshalAs(UnmanagedType.LPWStr)> options As String   ' LPCWSTR
) As Integer
End Function
' layerPath : LPCWSTR
' vhdHandle : HANDLE
' options : LPCWSTR
Declare PtrSafe Function HcsSetupBaseOSLayer Lib "computestorage" ( _
    ByVal layerPath As LongPtr, _
    ByVal vhdHandle 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

HcsSetupBaseOSLayer = ctypes.windll.computestorage.HcsSetupBaseOSLayer
HcsSetupBaseOSLayer.restype = ctypes.c_int
HcsSetupBaseOSLayer.argtypes = [
    wintypes.LPCWSTR,  # layerPath : LPCWSTR
    wintypes.HANDLE,  # vhdHandle : HANDLE
    wintypes.LPCWSTR,  # options : LPCWSTR
]
require 'fiddle'
require 'fiddle/import'

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

var (
	computestorage = windows.NewLazySystemDLL("computestorage.dll")
	procHcsSetupBaseOSLayer = computestorage.NewProc("HcsSetupBaseOSLayer")
)

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