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

HcsGrantVmGroupAccess

関数
指定ファイルへのVMグループアクセス権を付与する。
DLLcomputecore.dll呼出規約winapi

シグネチャ

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

HRESULT HcsGrantVmGroupAccess(
    LPCWSTR filePath
);

パラメーター

名前方向
filePathLPCWSTRin

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT HcsGrantVmGroupAccess(
    LPCWSTR filePath
);
[DllImport("computecore.dll", ExactSpelling = true)]
static extern int HcsGrantVmGroupAccess(
    [MarshalAs(UnmanagedType.LPWStr)] string filePath   // LPCWSTR
);
<DllImport("computecore.dll", ExactSpelling:=True)>
Public Shared Function HcsGrantVmGroupAccess(
    <MarshalAs(UnmanagedType.LPWStr)> filePath As String   ' LPCWSTR
) As Integer
End Function
' filePath : LPCWSTR
Declare PtrSafe Function HcsGrantVmGroupAccess Lib "computecore" ( _
    ByVal filePath As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

HcsGrantVmGroupAccess = ctypes.windll.computecore.HcsGrantVmGroupAccess
HcsGrantVmGroupAccess.restype = ctypes.c_int
HcsGrantVmGroupAccess.argtypes = [
    wintypes.LPCWSTR,  # filePath : LPCWSTR
]
require 'fiddle'
require 'fiddle/import'

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

var (
	computecore = windows.NewLazySystemDLL("computecore.dll")
	procHcsGrantVmGroupAccess = computecore.NewProc("HcsGrantVmGroupAccess")
)

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