Win32 API 日本語リファレンス
ホームStorage.Vhd › GetAllAttachedVirtualDiskPhysicalPaths

GetAllAttachedVirtualDiskPhysicalPaths

関数
接続中の全仮想ディスクの物理パス一覧を取得する。
DLLVirtDisk.dll呼出規約winapi

シグネチャ

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

WIN32_ERROR GetAllAttachedVirtualDiskPhysicalPaths(
    DWORD* PathsBufferSizeInBytes,
    LPWSTR PathsBuffer
);

パラメーター

名前方向
PathsBufferSizeInBytesDWORD*inout
PathsBufferLPWSTRout

戻り値の型: WIN32_ERROR

各言語での呼び出し定義

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

WIN32_ERROR GetAllAttachedVirtualDiskPhysicalPaths(
    DWORD* PathsBufferSizeInBytes,
    LPWSTR PathsBuffer
);
[DllImport("VirtDisk.dll", ExactSpelling = true)]
static extern uint GetAllAttachedVirtualDiskPhysicalPaths(
    ref uint PathsBufferSizeInBytes,   // DWORD* in/out
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder PathsBuffer   // LPWSTR out
);
<DllImport("VirtDisk.dll", ExactSpelling:=True)>
Public Shared Function GetAllAttachedVirtualDiskPhysicalPaths(
    ByRef PathsBufferSizeInBytes As UInteger,   ' DWORD* in/out
    <MarshalAs(UnmanagedType.LPWStr)> PathsBuffer As System.Text.StringBuilder   ' LPWSTR out
) As UInteger
End Function
' PathsBufferSizeInBytes : DWORD* in/out
' PathsBuffer : LPWSTR out
Declare PtrSafe Function GetAllAttachedVirtualDiskPhysicalPaths Lib "virtdisk" ( _
    ByRef PathsBufferSizeInBytes As Long, _
    ByVal PathsBuffer As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetAllAttachedVirtualDiskPhysicalPaths = ctypes.windll.virtdisk.GetAllAttachedVirtualDiskPhysicalPaths
GetAllAttachedVirtualDiskPhysicalPaths.restype = wintypes.DWORD
GetAllAttachedVirtualDiskPhysicalPaths.argtypes = [
    ctypes.POINTER(wintypes.DWORD),  # PathsBufferSizeInBytes : DWORD* in/out
    wintypes.LPWSTR,  # PathsBuffer : LPWSTR out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('VirtDisk.dll')
GetAllAttachedVirtualDiskPhysicalPaths = Fiddle::Function.new(
  lib['GetAllAttachedVirtualDiskPhysicalPaths'],
  [
    Fiddle::TYPE_VOIDP,  # PathsBufferSizeInBytes : DWORD* in/out
    Fiddle::TYPE_VOIDP,  # PathsBuffer : LPWSTR out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "virtdisk")]
extern "system" {
    fn GetAllAttachedVirtualDiskPhysicalPaths(
        PathsBufferSizeInBytes: *mut u32,  // DWORD* in/out
        PathsBuffer: *mut u16  // LPWSTR out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("VirtDisk.dll")]
public static extern uint GetAllAttachedVirtualDiskPhysicalPaths(ref uint PathsBufferSizeInBytes, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder PathsBuffer);
"@
$api = Add-Type -MemberDefinition $sig -Name 'VirtDisk_GetAllAttachedVirtualDiskPhysicalPaths' -Namespace Win32 -PassThru
# $api::GetAllAttachedVirtualDiskPhysicalPaths(PathsBufferSizeInBytes, PathsBuffer)
#uselib "VirtDisk.dll"
#func global GetAllAttachedVirtualDiskPhysicalPaths "GetAllAttachedVirtualDiskPhysicalPaths" sptr, sptr
; GetAllAttachedVirtualDiskPhysicalPaths varptr(PathsBufferSizeInBytes), varptr(PathsBuffer)   ; 戻り値は stat
; PathsBufferSizeInBytes : DWORD* in/out -> "sptr"
; PathsBuffer : LPWSTR out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "VirtDisk.dll"
#cfunc global GetAllAttachedVirtualDiskPhysicalPaths "GetAllAttachedVirtualDiskPhysicalPaths" var, var
; res = GetAllAttachedVirtualDiskPhysicalPaths(PathsBufferSizeInBytes, PathsBuffer)
; PathsBufferSizeInBytes : DWORD* in/out -> "var"
; PathsBuffer : LPWSTR out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; WIN32_ERROR GetAllAttachedVirtualDiskPhysicalPaths(DWORD* PathsBufferSizeInBytes, LPWSTR PathsBuffer)
#uselib "VirtDisk.dll"
#cfunc global GetAllAttachedVirtualDiskPhysicalPaths "GetAllAttachedVirtualDiskPhysicalPaths" var, var
; res = GetAllAttachedVirtualDiskPhysicalPaths(PathsBufferSizeInBytes, PathsBuffer)
; PathsBufferSizeInBytes : DWORD* in/out -> "var"
; PathsBuffer : LPWSTR out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	virtdisk = windows.NewLazySystemDLL("VirtDisk.dll")
	procGetAllAttachedVirtualDiskPhysicalPaths = virtdisk.NewProc("GetAllAttachedVirtualDiskPhysicalPaths")
)

// PathsBufferSizeInBytes (DWORD* in/out), PathsBuffer (LPWSTR out)
r1, _, err := procGetAllAttachedVirtualDiskPhysicalPaths.Call(
	uintptr(PathsBufferSizeInBytes),
	uintptr(PathsBuffer),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // WIN32_ERROR
function GetAllAttachedVirtualDiskPhysicalPaths(
  PathsBufferSizeInBytes: Pointer;   // DWORD* in/out
  PathsBuffer: PWideChar   // LPWSTR out
): DWORD; stdcall;
  external 'VirtDisk.dll' name 'GetAllAttachedVirtualDiskPhysicalPaths';
result := DllCall("VirtDisk\GetAllAttachedVirtualDiskPhysicalPaths"
    , "Ptr", PathsBufferSizeInBytes   ; DWORD* in/out
    , "Ptr", PathsBuffer   ; LPWSTR out
    , "UInt")   ; return: WIN32_ERROR
●GetAllAttachedVirtualDiskPhysicalPaths(PathsBufferSizeInBytes, PathsBuffer) = DLL("VirtDisk.dll", "dword GetAllAttachedVirtualDiskPhysicalPaths(void*, char*)")
# 呼び出し: GetAllAttachedVirtualDiskPhysicalPaths(PathsBufferSizeInBytes, PathsBuffer)
# PathsBufferSizeInBytes : DWORD* in/out -> "void*"
# PathsBuffer : LPWSTR out -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。