ホーム › System.HostComputeSystem › HcsGetLayerVhdMountPath
HcsGetLayerVhdMountPath
関数レイヤーVHDのマウントパスを取得する。
シグネチャ
// computestorage.dll
#include <windows.h>
HRESULT HcsGetLayerVhdMountPath(
HANDLE vhdHandle,
LPWSTR* mountPath
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| vhdHandle | HANDLE | in | マウントパスを取得する対象VHDのハンドル。 |
| mountPath | LPWSTR* | out | VHDのマウントパス文字列を受け取るポインタ。要解放。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// computestorage.dll
#include <windows.h>
HRESULT HcsGetLayerVhdMountPath(
HANDLE vhdHandle,
LPWSTR* mountPath
);[DllImport("computestorage.dll", ExactSpelling = true)]
static extern int HcsGetLayerVhdMountPath(
IntPtr vhdHandle, // HANDLE
IntPtr mountPath // LPWSTR* out
);<DllImport("computestorage.dll", ExactSpelling:=True)>
Public Shared Function HcsGetLayerVhdMountPath(
vhdHandle As IntPtr, ' HANDLE
mountPath As IntPtr ' LPWSTR* out
) As Integer
End Function' vhdHandle : HANDLE
' mountPath : LPWSTR* out
Declare PtrSafe Function HcsGetLayerVhdMountPath Lib "computestorage" ( _
ByVal vhdHandle As LongPtr, _
ByVal mountPath As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
HcsGetLayerVhdMountPath = ctypes.windll.computestorage.HcsGetLayerVhdMountPath
HcsGetLayerVhdMountPath.restype = ctypes.c_int
HcsGetLayerVhdMountPath.argtypes = [
wintypes.HANDLE, # vhdHandle : HANDLE
ctypes.c_void_p, # mountPath : LPWSTR* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('computestorage.dll')
HcsGetLayerVhdMountPath = Fiddle::Function.new(
lib['HcsGetLayerVhdMountPath'],
[
Fiddle::TYPE_VOIDP, # vhdHandle : HANDLE
Fiddle::TYPE_VOIDP, # mountPath : LPWSTR* out
],
Fiddle::TYPE_INT)#[link(name = "computestorage")]
extern "system" {
fn HcsGetLayerVhdMountPath(
vhdHandle: *mut core::ffi::c_void, // HANDLE
mountPath: *mut *mut u16 // LPWSTR* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("computestorage.dll")]
public static extern int HcsGetLayerVhdMountPath(IntPtr vhdHandle, IntPtr mountPath);
"@
$api = Add-Type -MemberDefinition $sig -Name 'computestorage_HcsGetLayerVhdMountPath' -Namespace Win32 -PassThru
# $api::HcsGetLayerVhdMountPath(vhdHandle, mountPath)#uselib "computestorage.dll"
#func global HcsGetLayerVhdMountPath "HcsGetLayerVhdMountPath" sptr, sptr
; HcsGetLayerVhdMountPath vhdHandle, varptr(mountPath) ; 戻り値は stat
; vhdHandle : HANDLE -> "sptr"
; mountPath : LPWSTR* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "computestorage.dll" #cfunc global HcsGetLayerVhdMountPath "HcsGetLayerVhdMountPath" sptr, var ; res = HcsGetLayerVhdMountPath(vhdHandle, mountPath) ; vhdHandle : HANDLE -> "sptr" ; mountPath : LPWSTR* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "computestorage.dll" #cfunc global HcsGetLayerVhdMountPath "HcsGetLayerVhdMountPath" sptr, sptr ; res = HcsGetLayerVhdMountPath(vhdHandle, varptr(mountPath)) ; vhdHandle : HANDLE -> "sptr" ; mountPath : LPWSTR* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT HcsGetLayerVhdMountPath(HANDLE vhdHandle, LPWSTR* mountPath) #uselib "computestorage.dll" #cfunc global HcsGetLayerVhdMountPath "HcsGetLayerVhdMountPath" intptr, var ; res = HcsGetLayerVhdMountPath(vhdHandle, mountPath) ; vhdHandle : HANDLE -> "intptr" ; mountPath : LPWSTR* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT HcsGetLayerVhdMountPath(HANDLE vhdHandle, LPWSTR* mountPath) #uselib "computestorage.dll" #cfunc global HcsGetLayerVhdMountPath "HcsGetLayerVhdMountPath" intptr, intptr ; res = HcsGetLayerVhdMountPath(vhdHandle, varptr(mountPath)) ; vhdHandle : HANDLE -> "intptr" ; mountPath : LPWSTR* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
computestorage = windows.NewLazySystemDLL("computestorage.dll")
procHcsGetLayerVhdMountPath = computestorage.NewProc("HcsGetLayerVhdMountPath")
)
// vhdHandle (HANDLE), mountPath (LPWSTR* out)
r1, _, err := procHcsGetLayerVhdMountPath.Call(
uintptr(vhdHandle),
uintptr(mountPath),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction HcsGetLayerVhdMountPath(
vhdHandle: THandle; // HANDLE
mountPath: PPWideChar // LPWSTR* out
): Integer; stdcall;
external 'computestorage.dll' name 'HcsGetLayerVhdMountPath';result := DllCall("computestorage\HcsGetLayerVhdMountPath"
, "Ptr", vhdHandle ; HANDLE
, "Ptr", mountPath ; LPWSTR* out
, "Int") ; return: HRESULT●HcsGetLayerVhdMountPath(vhdHandle, mountPath) = DLL("computestorage.dll", "int HcsGetLayerVhdMountPath(void*, void*)")
# 呼び出し: HcsGetLayerVhdMountPath(vhdHandle, mountPath)
# vhdHandle : HANDLE -> "void*"
# mountPath : LPWSTR* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "computestorage" fn HcsGetLayerVhdMountPath(
vhdHandle: ?*anyopaque, // HANDLE
mountPath: [*c][*c]u16 // LPWSTR* out
) callconv(std.os.windows.WINAPI) i32;proc HcsGetLayerVhdMountPath(
vhdHandle: pointer, # HANDLE
mountPath: ptr WideCString # LPWSTR* out
): int32 {.importc: "HcsGetLayerVhdMountPath", stdcall, dynlib: "computestorage.dll".}pragma(lib, "computestorage");
extern(Windows)
int HcsGetLayerVhdMountPath(
void* vhdHandle, // HANDLE
wchar** mountPath // LPWSTR* out
);ccall((:HcsGetLayerVhdMountPath, "computestorage.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{Ptr{UInt16}}),
vhdHandle, mountPath)
# vhdHandle : HANDLE -> Ptr{Cvoid}
# mountPath : LPWSTR* out -> Ptr{Ptr{UInt16}}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t HcsGetLayerVhdMountPath(
void* vhdHandle,
uint16_t** mountPath);
]]
local computestorage = ffi.load("computestorage")
-- computestorage.HcsGetLayerVhdMountPath(vhdHandle, mountPath)
-- vhdHandle : HANDLE
-- mountPath : LPWSTR* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('computestorage.dll');
const HcsGetLayerVhdMountPath = lib.func('__stdcall', 'HcsGetLayerVhdMountPath', 'int32_t', ['void *', 'void *']);
// HcsGetLayerVhdMountPath(vhdHandle, mountPath)
// vhdHandle : HANDLE -> 'void *'
// mountPath : LPWSTR* out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("computestorage.dll", {
HcsGetLayerVhdMountPath: { parameters: ["pointer", "pointer"], result: "i32" },
});
// lib.symbols.HcsGetLayerVhdMountPath(vhdHandle, mountPath)
// vhdHandle : HANDLE -> "pointer"
// mountPath : LPWSTR* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t HcsGetLayerVhdMountPath(
void* vhdHandle,
uint16_t** mountPath);
C, "computestorage.dll");
// $ffi->HcsGetLayerVhdMountPath(vhdHandle, mountPath);
// vhdHandle : HANDLE
// mountPath : LPWSTR* out
// 構造体/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 Computestorage extends StdCallLibrary {
Computestorage INSTANCE = Native.load("computestorage", Computestorage.class);
int HcsGetLayerVhdMountPath(
Pointer vhdHandle, // HANDLE
PointerByReference mountPath // LPWSTR* out
);
}@[Link("computestorage")]
lib Libcomputestorage
fun HcsGetLayerVhdMountPath = HcsGetLayerVhdMountPath(
vhdHandle : Void*, # HANDLE
mountPath : UInt16** # LPWSTR* out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef HcsGetLayerVhdMountPathNative = Int32 Function(Pointer<Void>, Pointer<Pointer<Utf16>>);
typedef HcsGetLayerVhdMountPathDart = int Function(Pointer<Void>, Pointer<Pointer<Utf16>>);
final HcsGetLayerVhdMountPath = DynamicLibrary.open('computestorage.dll')
.lookupFunction<HcsGetLayerVhdMountPathNative, HcsGetLayerVhdMountPathDart>('HcsGetLayerVhdMountPath');
// vhdHandle : HANDLE -> Pointer<Void>
// mountPath : LPWSTR* out -> Pointer<Pointer<Utf16>>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function HcsGetLayerVhdMountPath(
vhdHandle: THandle; // HANDLE
mountPath: PPWideChar // LPWSTR* out
): Integer; stdcall;
external 'computestorage.dll' name 'HcsGetLayerVhdMountPath';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "HcsGetLayerVhdMountPath"
c_HcsGetLayerVhdMountPath :: Ptr () -> Ptr CWString -> IO Int32
-- vhdHandle : HANDLE -> Ptr ()
-- mountPath : LPWSTR* out -> Ptr CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let hcsgetlayervhdmountpath =
foreign "HcsGetLayerVhdMountPath"
((ptr void) @-> (ptr (ptr uint16_t)) @-> returning int32_t)
(* vhdHandle : HANDLE -> (ptr void) *)
(* mountPath : LPWSTR* out -> (ptr (ptr uint16_t)) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library computestorage (t "computestorage.dll"))
(cffi:use-foreign-library computestorage)
(cffi:defcfun ("HcsGetLayerVhdMountPath" hcs-get-layer-vhd-mount-path :convention :stdcall) :int32
(vhd-handle :pointer) ; HANDLE
(mount-path :pointer)) ; LPWSTR* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $HcsGetLayerVhdMountPath = Win32::API::More->new('computestorage',
'int HcsGetLayerVhdMountPath(HANDLE vhdHandle, LPVOID mountPath)');
# my $ret = $HcsGetLayerVhdMountPath->Call($vhdHandle, $mountPath);
# vhdHandle : HANDLE -> HANDLE
# mountPath : LPWSTR* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。