ホーム › System.Hypervisor › LocateSavedStateFiles
LocateSavedStateFiles
関数VMの保存状態ファイルのパスを検索して取得する。
シグネチャ
// VmSavedStateDumpProvider.dll
#include <windows.h>
HRESULT LocateSavedStateFiles(
LPCWSTR vmName,
LPCWSTR snapshotName, // optional
LPWSTR* binPath,
LPWSTR* vsvPath,
LPWSTR* vmrsPath
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| vmName | LPCWSTR | in |
| snapshotName | LPCWSTR | inoptional |
| binPath | LPWSTR* | out |
| vsvPath | LPWSTR* | out |
| vmrsPath | LPWSTR* | out |
戻り値の型: HRESULT
各言語での呼び出し定義
// VmSavedStateDumpProvider.dll
#include <windows.h>
HRESULT LocateSavedStateFiles(
LPCWSTR vmName,
LPCWSTR snapshotName, // optional
LPWSTR* binPath,
LPWSTR* vsvPath,
LPWSTR* vmrsPath
);[DllImport("VmSavedStateDumpProvider.dll", ExactSpelling = true)]
static extern int LocateSavedStateFiles(
[MarshalAs(UnmanagedType.LPWStr)] string vmName, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string snapshotName, // LPCWSTR optional
IntPtr binPath, // LPWSTR* out
IntPtr vsvPath, // LPWSTR* out
IntPtr vmrsPath // LPWSTR* out
);<DllImport("VmSavedStateDumpProvider.dll", ExactSpelling:=True)>
Public Shared Function LocateSavedStateFiles(
<MarshalAs(UnmanagedType.LPWStr)> vmName As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> snapshotName As String, ' LPCWSTR optional
binPath As IntPtr, ' LPWSTR* out
vsvPath As IntPtr, ' LPWSTR* out
vmrsPath As IntPtr ' LPWSTR* out
) As Integer
End Function' vmName : LPCWSTR
' snapshotName : LPCWSTR optional
' binPath : LPWSTR* out
' vsvPath : LPWSTR* out
' vmrsPath : LPWSTR* out
Declare PtrSafe Function LocateSavedStateFiles Lib "vmsavedstatedumpprovider" ( _
ByVal vmName As LongPtr, _
ByVal snapshotName As LongPtr, _
ByVal binPath As LongPtr, _
ByVal vsvPath As LongPtr, _
ByVal vmrsPath As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
LocateSavedStateFiles = ctypes.windll.vmsavedstatedumpprovider.LocateSavedStateFiles
LocateSavedStateFiles.restype = ctypes.c_int
LocateSavedStateFiles.argtypes = [
wintypes.LPCWSTR, # vmName : LPCWSTR
wintypes.LPCWSTR, # snapshotName : LPCWSTR optional
ctypes.c_void_p, # binPath : LPWSTR* out
ctypes.c_void_p, # vsvPath : LPWSTR* out
ctypes.c_void_p, # vmrsPath : LPWSTR* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('VmSavedStateDumpProvider.dll')
LocateSavedStateFiles = Fiddle::Function.new(
lib['LocateSavedStateFiles'],
[
Fiddle::TYPE_VOIDP, # vmName : LPCWSTR
Fiddle::TYPE_VOIDP, # snapshotName : LPCWSTR optional
Fiddle::TYPE_VOIDP, # binPath : LPWSTR* out
Fiddle::TYPE_VOIDP, # vsvPath : LPWSTR* out
Fiddle::TYPE_VOIDP, # vmrsPath : LPWSTR* out
],
Fiddle::TYPE_INT)#[link(name = "vmsavedstatedumpprovider")]
extern "system" {
fn LocateSavedStateFiles(
vmName: *const u16, // LPCWSTR
snapshotName: *const u16, // LPCWSTR optional
binPath: *mut *mut u16, // LPWSTR* out
vsvPath: *mut *mut u16, // LPWSTR* out
vmrsPath: *mut *mut u16 // LPWSTR* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("VmSavedStateDumpProvider.dll")]
public static extern int LocateSavedStateFiles([MarshalAs(UnmanagedType.LPWStr)] string vmName, [MarshalAs(UnmanagedType.LPWStr)] string snapshotName, IntPtr binPath, IntPtr vsvPath, IntPtr vmrsPath);
"@
$api = Add-Type -MemberDefinition $sig -Name 'VmSavedStateDumpProvider_LocateSavedStateFiles' -Namespace Win32 -PassThru
# $api::LocateSavedStateFiles(vmName, snapshotName, binPath, vsvPath, vmrsPath)#uselib "VmSavedStateDumpProvider.dll"
#func global LocateSavedStateFiles "LocateSavedStateFiles" sptr, sptr, sptr, sptr, sptr
; LocateSavedStateFiles vmName, snapshotName, varptr(binPath), varptr(vsvPath), varptr(vmrsPath) ; 戻り値は stat
; vmName : LPCWSTR -> "sptr"
; snapshotName : LPCWSTR optional -> "sptr"
; binPath : LPWSTR* out -> "sptr"
; vsvPath : LPWSTR* out -> "sptr"
; vmrsPath : LPWSTR* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "VmSavedStateDumpProvider.dll" #cfunc global LocateSavedStateFiles "LocateSavedStateFiles" wstr, wstr, var, var, var ; res = LocateSavedStateFiles(vmName, snapshotName, binPath, vsvPath, vmrsPath) ; vmName : LPCWSTR -> "wstr" ; snapshotName : LPCWSTR optional -> "wstr" ; binPath : LPWSTR* out -> "var" ; vsvPath : LPWSTR* out -> "var" ; vmrsPath : LPWSTR* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "VmSavedStateDumpProvider.dll" #cfunc global LocateSavedStateFiles "LocateSavedStateFiles" wstr, wstr, sptr, sptr, sptr ; res = LocateSavedStateFiles(vmName, snapshotName, varptr(binPath), varptr(vsvPath), varptr(vmrsPath)) ; vmName : LPCWSTR -> "wstr" ; snapshotName : LPCWSTR optional -> "wstr" ; binPath : LPWSTR* out -> "sptr" ; vsvPath : LPWSTR* out -> "sptr" ; vmrsPath : LPWSTR* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT LocateSavedStateFiles(LPCWSTR vmName, LPCWSTR snapshotName, LPWSTR* binPath, LPWSTR* vsvPath, LPWSTR* vmrsPath) #uselib "VmSavedStateDumpProvider.dll" #cfunc global LocateSavedStateFiles "LocateSavedStateFiles" wstr, wstr, var, var, var ; res = LocateSavedStateFiles(vmName, snapshotName, binPath, vsvPath, vmrsPath) ; vmName : LPCWSTR -> "wstr" ; snapshotName : LPCWSTR optional -> "wstr" ; binPath : LPWSTR* out -> "var" ; vsvPath : LPWSTR* out -> "var" ; vmrsPath : LPWSTR* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT LocateSavedStateFiles(LPCWSTR vmName, LPCWSTR snapshotName, LPWSTR* binPath, LPWSTR* vsvPath, LPWSTR* vmrsPath) #uselib "VmSavedStateDumpProvider.dll" #cfunc global LocateSavedStateFiles "LocateSavedStateFiles" wstr, wstr, intptr, intptr, intptr ; res = LocateSavedStateFiles(vmName, snapshotName, varptr(binPath), varptr(vsvPath), varptr(vmrsPath)) ; vmName : LPCWSTR -> "wstr" ; snapshotName : LPCWSTR optional -> "wstr" ; binPath : LPWSTR* out -> "intptr" ; vsvPath : LPWSTR* out -> "intptr" ; vmrsPath : LPWSTR* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
vmsavedstatedumpprovider = windows.NewLazySystemDLL("VmSavedStateDumpProvider.dll")
procLocateSavedStateFiles = vmsavedstatedumpprovider.NewProc("LocateSavedStateFiles")
)
// vmName (LPCWSTR), snapshotName (LPCWSTR optional), binPath (LPWSTR* out), vsvPath (LPWSTR* out), vmrsPath (LPWSTR* out)
r1, _, err := procLocateSavedStateFiles.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(vmName))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(snapshotName))),
uintptr(binPath),
uintptr(vsvPath),
uintptr(vmrsPath),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction LocateSavedStateFiles(
vmName: PWideChar; // LPCWSTR
snapshotName: PWideChar; // LPCWSTR optional
binPath: PPWideChar; // LPWSTR* out
vsvPath: PPWideChar; // LPWSTR* out
vmrsPath: PPWideChar // LPWSTR* out
): Integer; stdcall;
external 'VmSavedStateDumpProvider.dll' name 'LocateSavedStateFiles';result := DllCall("VmSavedStateDumpProvider\LocateSavedStateFiles"
, "WStr", vmName ; LPCWSTR
, "WStr", snapshotName ; LPCWSTR optional
, "Ptr", binPath ; LPWSTR* out
, "Ptr", vsvPath ; LPWSTR* out
, "Ptr", vmrsPath ; LPWSTR* out
, "Int") ; return: HRESULT●LocateSavedStateFiles(vmName, snapshotName, binPath, vsvPath, vmrsPath) = DLL("VmSavedStateDumpProvider.dll", "int LocateSavedStateFiles(char*, char*, void*, void*, void*)")
# 呼び出し: LocateSavedStateFiles(vmName, snapshotName, binPath, vsvPath, vmrsPath)
# vmName : LPCWSTR -> "char*"
# snapshotName : LPCWSTR optional -> "char*"
# binPath : LPWSTR* out -> "void*"
# vsvPath : LPWSTR* out -> "void*"
# vmrsPath : LPWSTR* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。