ホーム › System.HostComputeSystem › HcsGrantVmAccess
HcsGrantVmAccess
関数指定ファイルへのVMアクセス権を付与する。
シグネチャ
// computecore.dll
#include <windows.h>
HRESULT HcsGrantVmAccess(
LPCWSTR vmId,
LPCWSTR filePath
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| vmId | LPCWSTR | in |
| filePath | LPCWSTR | in |
戻り値の型: HRESULT
各言語での呼び出し定義
// computecore.dll
#include <windows.h>
HRESULT HcsGrantVmAccess(
LPCWSTR vmId,
LPCWSTR filePath
);[DllImport("computecore.dll", ExactSpelling = true)]
static extern int HcsGrantVmAccess(
[MarshalAs(UnmanagedType.LPWStr)] string vmId, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string filePath // LPCWSTR
);<DllImport("computecore.dll", ExactSpelling:=True)>
Public Shared Function HcsGrantVmAccess(
<MarshalAs(UnmanagedType.LPWStr)> vmId As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> filePath As String ' LPCWSTR
) As Integer
End Function' vmId : LPCWSTR
' filePath : LPCWSTR
Declare PtrSafe Function HcsGrantVmAccess Lib "computecore" ( _
ByVal vmId As LongPtr, _
ByVal filePath As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
HcsGrantVmAccess = ctypes.windll.computecore.HcsGrantVmAccess
HcsGrantVmAccess.restype = ctypes.c_int
HcsGrantVmAccess.argtypes = [
wintypes.LPCWSTR, # vmId : LPCWSTR
wintypes.LPCWSTR, # filePath : LPCWSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('computecore.dll')
HcsGrantVmAccess = Fiddle::Function.new(
lib['HcsGrantVmAccess'],
[
Fiddle::TYPE_VOIDP, # vmId : LPCWSTR
Fiddle::TYPE_VOIDP, # filePath : LPCWSTR
],
Fiddle::TYPE_INT)#[link(name = "computecore")]
extern "system" {
fn HcsGrantVmAccess(
vmId: *const u16, // LPCWSTR
filePath: *const u16 // LPCWSTR
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("computecore.dll")]
public static extern int HcsGrantVmAccess([MarshalAs(UnmanagedType.LPWStr)] string vmId, [MarshalAs(UnmanagedType.LPWStr)] string filePath);
"@
$api = Add-Type -MemberDefinition $sig -Name 'computecore_HcsGrantVmAccess' -Namespace Win32 -PassThru
# $api::HcsGrantVmAccess(vmId, filePath)#uselib "computecore.dll"
#func global HcsGrantVmAccess "HcsGrantVmAccess" sptr, sptr
; HcsGrantVmAccess vmId, filePath ; 戻り値は stat
; vmId : LPCWSTR -> "sptr"
; filePath : LPCWSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "computecore.dll"
#cfunc global HcsGrantVmAccess "HcsGrantVmAccess" wstr, wstr
; res = HcsGrantVmAccess(vmId, filePath)
; vmId : LPCWSTR -> "wstr"
; filePath : LPCWSTR -> "wstr"; HRESULT HcsGrantVmAccess(LPCWSTR vmId, LPCWSTR filePath)
#uselib "computecore.dll"
#cfunc global HcsGrantVmAccess "HcsGrantVmAccess" wstr, wstr
; res = HcsGrantVmAccess(vmId, filePath)
; vmId : LPCWSTR -> "wstr"
; filePath : LPCWSTR -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
computecore = windows.NewLazySystemDLL("computecore.dll")
procHcsGrantVmAccess = computecore.NewProc("HcsGrantVmAccess")
)
// vmId (LPCWSTR), filePath (LPCWSTR)
r1, _, err := procHcsGrantVmAccess.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(vmId))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(filePath))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction HcsGrantVmAccess(
vmId: PWideChar; // LPCWSTR
filePath: PWideChar // LPCWSTR
): Integer; stdcall;
external 'computecore.dll' name 'HcsGrantVmAccess';result := DllCall("computecore\HcsGrantVmAccess"
, "WStr", vmId ; LPCWSTR
, "WStr", filePath ; LPCWSTR
, "Int") ; return: HRESULT●HcsGrantVmAccess(vmId, filePath) = DLL("computecore.dll", "int HcsGrantVmAccess(char*, char*)")
# 呼び出し: HcsGrantVmAccess(vmId, filePath)
# vmId : LPCWSTR -> "char*"
# filePath : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。