ホーム › System.SystemInformation › RtlSwitchedVVI
RtlSwitchedVVI
関数条件マスクを用いてOSバージョン情報を検証する内部関数。
シグネチャ
// ntdll.dll
#include <windows.h>
DWORD RtlSwitchedVVI(
OSVERSIONINFOEXW* VersionInfo,
DWORD TypeMask,
ULONGLONG ConditionMask
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| VersionInfo | OSVERSIONINFOEXW* | in | 比較対象の OS バージョン情報を格納した OSVERSIONINFOEXW 構造体。 |
| TypeMask | DWORD | in | 比較する要素(VER_MAJORVERSION 等)を示すフラグ。 |
| ConditionMask | ULONGLONG | in | 各要素の比較演算子を符号化した条件マスク値。 |
戻り値の型: DWORD
各言語での呼び出し定義
// ntdll.dll
#include <windows.h>
DWORD RtlSwitchedVVI(
OSVERSIONINFOEXW* VersionInfo,
DWORD TypeMask,
ULONGLONG ConditionMask
);[DllImport("ntdll.dll", ExactSpelling = true)]
static extern uint RtlSwitchedVVI(
IntPtr VersionInfo, // OSVERSIONINFOEXW*
uint TypeMask, // DWORD
ulong ConditionMask // ULONGLONG
);<DllImport("ntdll.dll", ExactSpelling:=True)>
Public Shared Function RtlSwitchedVVI(
VersionInfo As IntPtr, ' OSVERSIONINFOEXW*
TypeMask As UInteger, ' DWORD
ConditionMask As ULong ' ULONGLONG
) As UInteger
End Function' VersionInfo : OSVERSIONINFOEXW*
' TypeMask : DWORD
' ConditionMask : ULONGLONG
Declare PtrSafe Function RtlSwitchedVVI Lib "ntdll" ( _
ByVal VersionInfo As LongPtr, _
ByVal TypeMask As Long, _
ByVal ConditionMask As LongLong) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
RtlSwitchedVVI = ctypes.windll.ntdll.RtlSwitchedVVI
RtlSwitchedVVI.restype = wintypes.DWORD
RtlSwitchedVVI.argtypes = [
ctypes.c_void_p, # VersionInfo : OSVERSIONINFOEXW*
wintypes.DWORD, # TypeMask : DWORD
ctypes.c_ulonglong, # ConditionMask : ULONGLONG
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ntdll.dll')
RtlSwitchedVVI = Fiddle::Function.new(
lib['RtlSwitchedVVI'],
[
Fiddle::TYPE_VOIDP, # VersionInfo : OSVERSIONINFOEXW*
-Fiddle::TYPE_INT, # TypeMask : DWORD
-Fiddle::TYPE_LONG_LONG, # ConditionMask : ULONGLONG
],
-Fiddle::TYPE_INT)#[link(name = "ntdll")]
extern "system" {
fn RtlSwitchedVVI(
VersionInfo: *mut OSVERSIONINFOEXW, // OSVERSIONINFOEXW*
TypeMask: u32, // DWORD
ConditionMask: u64 // ULONGLONG
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ntdll.dll")]
public static extern uint RtlSwitchedVVI(IntPtr VersionInfo, uint TypeMask, ulong ConditionMask);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ntdll_RtlSwitchedVVI' -Namespace Win32 -PassThru
# $api::RtlSwitchedVVI(VersionInfo, TypeMask, ConditionMask)#uselib "ntdll.dll"
#func global RtlSwitchedVVI "RtlSwitchedVVI" sptr, sptr, sptr
; RtlSwitchedVVI varptr(VersionInfo), TypeMask, ConditionMask ; 戻り値は stat
; VersionInfo : OSVERSIONINFOEXW* -> "sptr"
; TypeMask : DWORD -> "sptr"
; ConditionMask : ULONGLONG -> "sptr"
; ※HSP3.7は int64 引数(64bit値渡し)に非対応です。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "ntdll.dll" #cfunc global RtlSwitchedVVI "RtlSwitchedVVI" var, int, int64 ; res = RtlSwitchedVVI(VersionInfo, TypeMask, ConditionMask) ; VersionInfo : OSVERSIONINFOEXW* -> "var" ; TypeMask : DWORD -> "int" ; ConditionMask : ULONGLONG -> "int64" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。 ; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。#uselib "ntdll.dll" #cfunc global RtlSwitchedVVI "RtlSwitchedVVI" sptr, int, int64 ; res = RtlSwitchedVVI(varptr(VersionInfo), TypeMask, ConditionMask) ; VersionInfo : OSVERSIONINFOEXW* -> "sptr" ; TypeMask : DWORD -> "int" ; ConditionMask : ULONGLONG -> "int64" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。 ; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。
出力引数:
; DWORD RtlSwitchedVVI(OSVERSIONINFOEXW* VersionInfo, DWORD TypeMask, ULONGLONG ConditionMask) #uselib "ntdll.dll" #cfunc global RtlSwitchedVVI "RtlSwitchedVVI" var, int, int64 ; res = RtlSwitchedVVI(VersionInfo, TypeMask, ConditionMask) ; VersionInfo : OSVERSIONINFOEXW* -> "var" ; TypeMask : DWORD -> "int" ; ConditionMask : ULONGLONG -> "int64" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD RtlSwitchedVVI(OSVERSIONINFOEXW* VersionInfo, DWORD TypeMask, ULONGLONG ConditionMask) #uselib "ntdll.dll" #cfunc global RtlSwitchedVVI "RtlSwitchedVVI" intptr, int, int64 ; res = RtlSwitchedVVI(varptr(VersionInfo), TypeMask, ConditionMask) ; VersionInfo : OSVERSIONINFOEXW* -> "intptr" ; TypeMask : DWORD -> "int" ; ConditionMask : ULONGLONG -> "int64" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
ntdll = windows.NewLazySystemDLL("ntdll.dll")
procRtlSwitchedVVI = ntdll.NewProc("RtlSwitchedVVI")
)
// VersionInfo (OSVERSIONINFOEXW*), TypeMask (DWORD), ConditionMask (ULONGLONG)
r1, _, err := procRtlSwitchedVVI.Call(
uintptr(VersionInfo),
uintptr(TypeMask),
uintptr(ConditionMask),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction RtlSwitchedVVI(
VersionInfo: Pointer; // OSVERSIONINFOEXW*
TypeMask: DWORD; // DWORD
ConditionMask: UInt64 // ULONGLONG
): DWORD; stdcall;
external 'ntdll.dll' name 'RtlSwitchedVVI';result := DllCall("ntdll\RtlSwitchedVVI"
, "Ptr", VersionInfo ; OSVERSIONINFOEXW*
, "UInt", TypeMask ; DWORD
, "Int64", ConditionMask ; ULONGLONG
, "UInt") ; return: DWORD●RtlSwitchedVVI(VersionInfo, TypeMask, ConditionMask) = DLL("ntdll.dll", "dword RtlSwitchedVVI(void*, dword, qword)")
# 呼び出し: RtlSwitchedVVI(VersionInfo, TypeMask, ConditionMask)
# VersionInfo : OSVERSIONINFOEXW* -> "void*"
# TypeMask : DWORD -> "dword"
# ConditionMask : ULONGLONG -> "qword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "ntdll" fn RtlSwitchedVVI(
VersionInfo: [*c]OSVERSIONINFOEXW, // OSVERSIONINFOEXW*
TypeMask: u32, // DWORD
ConditionMask: u64 // ULONGLONG
) callconv(std.os.windows.WINAPI) u32;proc RtlSwitchedVVI(
VersionInfo: ptr OSVERSIONINFOEXW, # OSVERSIONINFOEXW*
TypeMask: uint32, # DWORD
ConditionMask: uint64 # ULONGLONG
): uint32 {.importc: "RtlSwitchedVVI", stdcall, dynlib: "ntdll.dll".}pragma(lib, "ntdll");
extern(Windows)
uint RtlSwitchedVVI(
OSVERSIONINFOEXW* VersionInfo, // OSVERSIONINFOEXW*
uint TypeMask, // DWORD
ulong ConditionMask // ULONGLONG
);ccall((:RtlSwitchedVVI, "ntdll.dll"), stdcall, UInt32,
(Ptr{OSVERSIONINFOEXW}, UInt32, UInt64),
VersionInfo, TypeMask, ConditionMask)
# VersionInfo : OSVERSIONINFOEXW* -> Ptr{OSVERSIONINFOEXW}
# TypeMask : DWORD -> UInt32
# ConditionMask : ULONGLONG -> UInt64
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t RtlSwitchedVVI(
void* VersionInfo,
uint32_t TypeMask,
uint64_t ConditionMask);
]]
local ntdll = ffi.load("ntdll")
-- ntdll.RtlSwitchedVVI(VersionInfo, TypeMask, ConditionMask)
-- VersionInfo : OSVERSIONINFOEXW*
-- TypeMask : DWORD
-- ConditionMask : ULONGLONG
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('ntdll.dll');
const RtlSwitchedVVI = lib.func('__stdcall', 'RtlSwitchedVVI', 'uint32_t', ['void *', 'uint32_t', 'uint64_t']);
// RtlSwitchedVVI(VersionInfo, TypeMask, ConditionMask)
// VersionInfo : OSVERSIONINFOEXW* -> 'void *'
// TypeMask : DWORD -> 'uint32_t'
// ConditionMask : ULONGLONG -> 'uint64_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("ntdll.dll", {
RtlSwitchedVVI: { parameters: ["pointer", "u32", "u64"], result: "u32" },
});
// lib.symbols.RtlSwitchedVVI(VersionInfo, TypeMask, ConditionMask)
// VersionInfo : OSVERSIONINFOEXW* -> "pointer"
// TypeMask : DWORD -> "u32"
// ConditionMask : ULONGLONG -> "u64"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t RtlSwitchedVVI(
void* VersionInfo,
uint32_t TypeMask,
uint64_t ConditionMask);
C, "ntdll.dll");
// $ffi->RtlSwitchedVVI(VersionInfo, TypeMask, ConditionMask);
// VersionInfo : OSVERSIONINFOEXW*
// TypeMask : DWORD
// ConditionMask : ULONGLONG
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Ntdll extends StdCallLibrary {
Ntdll INSTANCE = Native.load("ntdll", Ntdll.class);
int RtlSwitchedVVI(
Pointer VersionInfo, // OSVERSIONINFOEXW*
int TypeMask, // DWORD
long ConditionMask // ULONGLONG
);
}@[Link("ntdll")]
lib Libntdll
fun RtlSwitchedVVI = RtlSwitchedVVI(
VersionInfo : OSVERSIONINFOEXW*, # OSVERSIONINFOEXW*
TypeMask : UInt32, # DWORD
ConditionMask : UInt64 # ULONGLONG
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef RtlSwitchedVVINative = Uint32 Function(Pointer<Void>, Uint32, Uint64);
typedef RtlSwitchedVVIDart = int Function(Pointer<Void>, int, int);
final RtlSwitchedVVI = DynamicLibrary.open('ntdll.dll')
.lookupFunction<RtlSwitchedVVINative, RtlSwitchedVVIDart>('RtlSwitchedVVI');
// VersionInfo : OSVERSIONINFOEXW* -> Pointer<Void>
// TypeMask : DWORD -> Uint32
// ConditionMask : ULONGLONG -> Uint64
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function RtlSwitchedVVI(
VersionInfo: Pointer; // OSVERSIONINFOEXW*
TypeMask: DWORD; // DWORD
ConditionMask: UInt64 // ULONGLONG
): DWORD; stdcall;
external 'ntdll.dll' name 'RtlSwitchedVVI';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "RtlSwitchedVVI"
c_RtlSwitchedVVI :: Ptr () -> Word32 -> Word64 -> IO Word32
-- VersionInfo : OSVERSIONINFOEXW* -> Ptr ()
-- TypeMask : DWORD -> Word32
-- ConditionMask : ULONGLONG -> Word64
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let rtlswitchedvvi =
foreign "RtlSwitchedVVI"
((ptr void) @-> uint32_t @-> uint64_t @-> returning uint32_t)
(* VersionInfo : OSVERSIONINFOEXW* -> (ptr void) *)
(* TypeMask : DWORD -> uint32_t *)
(* ConditionMask : ULONGLONG -> uint64_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library ntdll (t "ntdll.dll"))
(cffi:use-foreign-library ntdll)
(cffi:defcfun ("RtlSwitchedVVI" rtl-switched-vvi :convention :stdcall) :uint32
(version-info :pointer) ; OSVERSIONINFOEXW*
(type-mask :uint32) ; DWORD
(condition-mask :uint64)) ; ULONGLONG
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $RtlSwitchedVVI = Win32::API::More->new('ntdll',
'DWORD RtlSwitchedVVI(LPVOID VersionInfo, DWORD TypeMask, UINT64 ConditionMask)');
# my $ret = $RtlSwitchedVVI->Call($VersionInfo, $TypeMask, $ConditionMask);
# VersionInfo : OSVERSIONINFOEXW* -> LPVOID
# TypeMask : DWORD -> DWORD
# ConditionMask : ULONGLONG -> UINT64
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型