ホーム › System.Hypervisor › WHvSetVpciDevicePowerState
WHvSetVpciDevicePowerState
関数仮想PCIデバイスの電源状態を設定する。
シグネチャ
// WinHvPlatform.dll
#include <windows.h>
HRESULT WHvSetVpciDevicePowerState(
WHV_PARTITION_HANDLE Partition,
ULONGLONG LogicalDeviceId,
DEVICE_POWER_STATE PowerState
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| Partition | WHV_PARTITION_HANDLE | in |
| LogicalDeviceId | ULONGLONG | in |
| PowerState | DEVICE_POWER_STATE | in |
戻り値の型: HRESULT
各言語での呼び出し定義
// WinHvPlatform.dll
#include <windows.h>
HRESULT WHvSetVpciDevicePowerState(
WHV_PARTITION_HANDLE Partition,
ULONGLONG LogicalDeviceId,
DEVICE_POWER_STATE PowerState
);[DllImport("WinHvPlatform.dll", ExactSpelling = true)]
static extern int WHvSetVpciDevicePowerState(
IntPtr Partition, // WHV_PARTITION_HANDLE
ulong LogicalDeviceId, // ULONGLONG
int PowerState // DEVICE_POWER_STATE
);<DllImport("WinHvPlatform.dll", ExactSpelling:=True)>
Public Shared Function WHvSetVpciDevicePowerState(
Partition As IntPtr, ' WHV_PARTITION_HANDLE
LogicalDeviceId As ULong, ' ULONGLONG
PowerState As Integer ' DEVICE_POWER_STATE
) As Integer
End Function' Partition : WHV_PARTITION_HANDLE
' LogicalDeviceId : ULONGLONG
' PowerState : DEVICE_POWER_STATE
Declare PtrSafe Function WHvSetVpciDevicePowerState Lib "winhvplatform" ( _
ByVal Partition As LongPtr, _
ByVal LogicalDeviceId As LongLong, _
ByVal PowerState As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
WHvSetVpciDevicePowerState = ctypes.windll.winhvplatform.WHvSetVpciDevicePowerState
WHvSetVpciDevicePowerState.restype = ctypes.c_int
WHvSetVpciDevicePowerState.argtypes = [
ctypes.c_ssize_t, # Partition : WHV_PARTITION_HANDLE
ctypes.c_ulonglong, # LogicalDeviceId : ULONGLONG
ctypes.c_int, # PowerState : DEVICE_POWER_STATE
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WinHvPlatform.dll')
WHvSetVpciDevicePowerState = Fiddle::Function.new(
lib['WHvSetVpciDevicePowerState'],
[
Fiddle::TYPE_INTPTR_T, # Partition : WHV_PARTITION_HANDLE
-Fiddle::TYPE_LONG_LONG, # LogicalDeviceId : ULONGLONG
Fiddle::TYPE_INT, # PowerState : DEVICE_POWER_STATE
],
Fiddle::TYPE_INT)#[link(name = "winhvplatform")]
extern "system" {
fn WHvSetVpciDevicePowerState(
Partition: isize, // WHV_PARTITION_HANDLE
LogicalDeviceId: u64, // ULONGLONG
PowerState: i32 // DEVICE_POWER_STATE
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("WinHvPlatform.dll")]
public static extern int WHvSetVpciDevicePowerState(IntPtr Partition, ulong LogicalDeviceId, int PowerState);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WinHvPlatform_WHvSetVpciDevicePowerState' -Namespace Win32 -PassThru
# $api::WHvSetVpciDevicePowerState(Partition, LogicalDeviceId, PowerState)#uselib "WinHvPlatform.dll"
#func global WHvSetVpciDevicePowerState "WHvSetVpciDevicePowerState" sptr, sptr, sptr
; WHvSetVpciDevicePowerState Partition, LogicalDeviceId, PowerState ; 戻り値は stat
; Partition : WHV_PARTITION_HANDLE -> "sptr"
; LogicalDeviceId : ULONGLONG -> "sptr"
; PowerState : DEVICE_POWER_STATE -> "sptr"
; ※HSP3.7は int64 引数(64bit値渡し)に非対応です。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "WinHvPlatform.dll"
#cfunc global WHvSetVpciDevicePowerState "WHvSetVpciDevicePowerState" sptr, int64, int
; res = WHvSetVpciDevicePowerState(Partition, LogicalDeviceId, PowerState)
; Partition : WHV_PARTITION_HANDLE -> "sptr"
; LogicalDeviceId : ULONGLONG -> "int64"
; PowerState : DEVICE_POWER_STATE -> "int"
; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。; HRESULT WHvSetVpciDevicePowerState(WHV_PARTITION_HANDLE Partition, ULONGLONG LogicalDeviceId, DEVICE_POWER_STATE PowerState)
#uselib "WinHvPlatform.dll"
#cfunc global WHvSetVpciDevicePowerState "WHvSetVpciDevicePowerState" intptr, int64, int
; res = WHvSetVpciDevicePowerState(Partition, LogicalDeviceId, PowerState)
; Partition : WHV_PARTITION_HANDLE -> "intptr"
; LogicalDeviceId : ULONGLONG -> "int64"
; PowerState : DEVICE_POWER_STATE -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
winhvplatform = windows.NewLazySystemDLL("WinHvPlatform.dll")
procWHvSetVpciDevicePowerState = winhvplatform.NewProc("WHvSetVpciDevicePowerState")
)
// Partition (WHV_PARTITION_HANDLE), LogicalDeviceId (ULONGLONG), PowerState (DEVICE_POWER_STATE)
r1, _, err := procWHvSetVpciDevicePowerState.Call(
uintptr(Partition),
uintptr(LogicalDeviceId),
uintptr(PowerState),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction WHvSetVpciDevicePowerState(
Partition: NativeInt; // WHV_PARTITION_HANDLE
LogicalDeviceId: UInt64; // ULONGLONG
PowerState: Integer // DEVICE_POWER_STATE
): Integer; stdcall;
external 'WinHvPlatform.dll' name 'WHvSetVpciDevicePowerState';result := DllCall("WinHvPlatform\WHvSetVpciDevicePowerState"
, "Ptr", Partition ; WHV_PARTITION_HANDLE
, "Int64", LogicalDeviceId ; ULONGLONG
, "Int", PowerState ; DEVICE_POWER_STATE
, "Int") ; return: HRESULT●WHvSetVpciDevicePowerState(Partition, LogicalDeviceId, PowerState) = DLL("WinHvPlatform.dll", "int WHvSetVpciDevicePowerState(int, qword, int)")
# 呼び出し: WHvSetVpciDevicePowerState(Partition, LogicalDeviceId, PowerState)
# Partition : WHV_PARTITION_HANDLE -> "int"
# LogicalDeviceId : ULONGLONG -> "qword"
# PowerState : DEVICE_POWER_STATE -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。