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

IsWow64GuestMachineSupported

関数
指定アーキテクチャのWOW64エミュレーション対応可否を調べる。
DLLKERNEL32.dll呼出規約winapiSetLastErrorあり対応OSWindows 10 以降

シグネチャ

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

HRESULT IsWow64GuestMachineSupported(
    IMAGE_FILE_MACHINE WowGuestMachine,
    BOOL* MachineIsSupported
);

パラメーター

名前方向
WowGuestMachineIMAGE_FILE_MACHINEin
MachineIsSupportedBOOL*out

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT IsWow64GuestMachineSupported(
    IMAGE_FILE_MACHINE WowGuestMachine,
    BOOL* MachineIsSupported
);
[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern int IsWow64GuestMachineSupported(
    ushort WowGuestMachine,   // IMAGE_FILE_MACHINE
    out int MachineIsSupported   // BOOL* out
);
<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function IsWow64GuestMachineSupported(
    WowGuestMachine As UShort,   ' IMAGE_FILE_MACHINE
    <Out> ByRef MachineIsSupported As Integer   ' BOOL* out
) As Integer
End Function
' WowGuestMachine : IMAGE_FILE_MACHINE
' MachineIsSupported : BOOL* out
Declare PtrSafe Function IsWow64GuestMachineSupported Lib "kernel32" ( _
    ByVal WowGuestMachine As Integer, _
    ByRef MachineIsSupported As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

IsWow64GuestMachineSupported = ctypes.windll.kernel32.IsWow64GuestMachineSupported
IsWow64GuestMachineSupported.restype = ctypes.c_int
IsWow64GuestMachineSupported.argtypes = [
    ctypes.c_ushort,  # WowGuestMachine : IMAGE_FILE_MACHINE
    ctypes.c_void_p,  # MachineIsSupported : BOOL* out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('KERNEL32.dll')
IsWow64GuestMachineSupported = Fiddle::Function.new(
  lib['IsWow64GuestMachineSupported'],
  [
    -Fiddle::TYPE_SHORT,  # WowGuestMachine : IMAGE_FILE_MACHINE
    Fiddle::TYPE_VOIDP,  # MachineIsSupported : BOOL* out
  ],
  Fiddle::TYPE_INT)
#[link(name = "kernel32")]
extern "system" {
    fn IsWow64GuestMachineSupported(
        WowGuestMachine: u16,  // IMAGE_FILE_MACHINE
        MachineIsSupported: *mut i32  // BOOL* out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("KERNEL32.dll", SetLastError = true)]
public static extern int IsWow64GuestMachineSupported(ushort WowGuestMachine, out int MachineIsSupported);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_IsWow64GuestMachineSupported' -Namespace Win32 -PassThru
# $api::IsWow64GuestMachineSupported(WowGuestMachine, MachineIsSupported)
#uselib "KERNEL32.dll"
#func global IsWow64GuestMachineSupported "IsWow64GuestMachineSupported" sptr, sptr
; IsWow64GuestMachineSupported WowGuestMachine, MachineIsSupported   ; 戻り値は stat
; WowGuestMachine : IMAGE_FILE_MACHINE -> "sptr"
; MachineIsSupported : BOOL* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "KERNEL32.dll"
#cfunc global IsWow64GuestMachineSupported "IsWow64GuestMachineSupported" int, int
; res = IsWow64GuestMachineSupported(WowGuestMachine, MachineIsSupported)
; WowGuestMachine : IMAGE_FILE_MACHINE -> "int"
; MachineIsSupported : BOOL* out -> "int"
; HRESULT IsWow64GuestMachineSupported(IMAGE_FILE_MACHINE WowGuestMachine, BOOL* MachineIsSupported)
#uselib "KERNEL32.dll"
#cfunc global IsWow64GuestMachineSupported "IsWow64GuestMachineSupported" int, int
; res = IsWow64GuestMachineSupported(WowGuestMachine, MachineIsSupported)
; WowGuestMachine : IMAGE_FILE_MACHINE -> "int"
; MachineIsSupported : BOOL* out -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procIsWow64GuestMachineSupported = kernel32.NewProc("IsWow64GuestMachineSupported")
)

// WowGuestMachine (IMAGE_FILE_MACHINE), MachineIsSupported (BOOL* out)
r1, _, err := procIsWow64GuestMachineSupported.Call(
	uintptr(WowGuestMachine),
	uintptr(MachineIsSupported),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function IsWow64GuestMachineSupported(
  WowGuestMachine: Word;   // IMAGE_FILE_MACHINE
  MachineIsSupported: Pointer   // BOOL* out
): Integer; stdcall;
  external 'KERNEL32.dll' name 'IsWow64GuestMachineSupported';
result := DllCall("KERNEL32\IsWow64GuestMachineSupported"
    , "UShort", WowGuestMachine   ; IMAGE_FILE_MACHINE
    , "Ptr", MachineIsSupported   ; BOOL* out
    , "Int")   ; return: HRESULT
●IsWow64GuestMachineSupported(WowGuestMachine, MachineIsSupported) = DLL("KERNEL32.dll", "int IsWow64GuestMachineSupported(int, void*)")
# 呼び出し: IsWow64GuestMachineSupported(WowGuestMachine, MachineIsSupported)
# WowGuestMachine : IMAGE_FILE_MACHINE -> "int"
# MachineIsSupported : BOOL* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。