Win32 API 日本語リファレンス
ホームDevices.DeviceAndDriverInstallation › CM_Is_Version_Available_Ex

CM_Is_Version_Available_Ex

関数
リモートマシンで指定バージョンが利用可能か判定する。
DLLCFGMGR32.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

BOOL CM_Is_Version_Available_Ex(
    WORD wVersion,
    INT_PTR hMachine   // optional
);

パラメーター

名前方向
wVersionWORDin
hMachineINT_PTRinoptional

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL CM_Is_Version_Available_Ex(
    WORD wVersion,
    INT_PTR hMachine   // optional
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("CFGMGR32.dll", ExactSpelling = true)]
static extern bool CM_Is_Version_Available_Ex(
    ushort wVersion,   // WORD
    IntPtr hMachine   // INT_PTR optional
);
<DllImport("CFGMGR32.dll", ExactSpelling:=True)>
Public Shared Function CM_Is_Version_Available_Ex(
    wVersion As UShort,   ' WORD
    hMachine As IntPtr   ' INT_PTR optional
) As Boolean
End Function
' wVersion : WORD
' hMachine : INT_PTR optional
Declare PtrSafe Function CM_Is_Version_Available_Ex Lib "cfgmgr32" ( _
    ByVal wVersion As Integer, _
    ByVal hMachine As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CM_Is_Version_Available_Ex = ctypes.windll.cfgmgr32.CM_Is_Version_Available_Ex
CM_Is_Version_Available_Ex.restype = wintypes.BOOL
CM_Is_Version_Available_Ex.argtypes = [
    ctypes.c_ushort,  # wVersion : WORD
    ctypes.c_ssize_t,  # hMachine : INT_PTR optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('CFGMGR32.dll')
CM_Is_Version_Available_Ex = Fiddle::Function.new(
  lib['CM_Is_Version_Available_Ex'],
  [
    -Fiddle::TYPE_SHORT,  # wVersion : WORD
    Fiddle::TYPE_INTPTR_T,  # hMachine : INT_PTR optional
  ],
  Fiddle::TYPE_INT)
#[link(name = "cfgmgr32")]
extern "system" {
    fn CM_Is_Version_Available_Ex(
        wVersion: u16,  // WORD
        hMachine: isize  // INT_PTR optional
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("CFGMGR32.dll")]
public static extern bool CM_Is_Version_Available_Ex(ushort wVersion, IntPtr hMachine);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CFGMGR32_CM_Is_Version_Available_Ex' -Namespace Win32 -PassThru
# $api::CM_Is_Version_Available_Ex(wVersion, hMachine)
#uselib "CFGMGR32.dll"
#func global CM_Is_Version_Available_Ex "CM_Is_Version_Available_Ex" sptr, sptr
; CM_Is_Version_Available_Ex wVersion, hMachine   ; 戻り値は stat
; wVersion : WORD -> "sptr"
; hMachine : INT_PTR optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "CFGMGR32.dll"
#cfunc global CM_Is_Version_Available_Ex "CM_Is_Version_Available_Ex" int, sptr
; res = CM_Is_Version_Available_Ex(wVersion, hMachine)
; wVersion : WORD -> "int"
; hMachine : INT_PTR optional -> "sptr"
; BOOL CM_Is_Version_Available_Ex(WORD wVersion, INT_PTR hMachine)
#uselib "CFGMGR32.dll"
#cfunc global CM_Is_Version_Available_Ex "CM_Is_Version_Available_Ex" int, intptr
; res = CM_Is_Version_Available_Ex(wVersion, hMachine)
; wVersion : WORD -> "int"
; hMachine : INT_PTR optional -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	cfgmgr32 = windows.NewLazySystemDLL("CFGMGR32.dll")
	procCM_Is_Version_Available_Ex = cfgmgr32.NewProc("CM_Is_Version_Available_Ex")
)

// wVersion (WORD), hMachine (INT_PTR optional)
r1, _, err := procCM_Is_Version_Available_Ex.Call(
	uintptr(wVersion),
	uintptr(hMachine),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function CM_Is_Version_Available_Ex(
  wVersion: Word;   // WORD
  hMachine: NativeInt   // INT_PTR optional
): BOOL; stdcall;
  external 'CFGMGR32.dll' name 'CM_Is_Version_Available_Ex';
result := DllCall("CFGMGR32\CM_Is_Version_Available_Ex"
    , "UShort", wVersion   ; WORD
    , "Ptr", hMachine   ; INT_PTR optional
    , "Int")   ; return: BOOL
●CM_Is_Version_Available_Ex(wVersion, hMachine) = DLL("CFGMGR32.dll", "bool CM_Is_Version_Available_Ex(int, int)")
# 呼び出し: CM_Is_Version_Available_Ex(wVersion, hMachine)
# wVersion : WORD -> "int"
# hMachine : INT_PTR optional -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。