VerSetConditionMask
関数シグネチャ
// KERNEL32.dll
#include <windows.h>
ULONGLONG VerSetConditionMask(
ULONGLONG ConditionMask,
VER_FLAGS TypeMask,
BYTE Condition
);パラメーター
| 名前 | 型 | 方向 | 説明 | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ConditionMask | ULONGLONG | in | VerifyVersionInfo 関数の dwlConditionMask パラメーターとして渡される値です。この関数は、比較情報をこの変数のビットに格納します。 VerSetCondition を最初に呼び出す前に、この変数を 0 に初期化してください。以降の呼び出しでは、前回の呼び出しで使用した変数を渡します。 | ||||||||||||||||||
| TypeMask | VER_FLAGS | in | 比較演算子を設定する対象である OSVERSIONINFOEX 構造体のメンバーを示すマスクです。この値は、VerifyVersionInfo 関数の dwTypeMask パラメーターで指定するビットのいずれか 1 つに対応します。このパラメーターには、次の値のいずれかを指定できます。
| ||||||||||||||||||
| Condition | BYTE | in | 比較に使用する演算子です。VerifyVersionInfo 関数は、この演算子を使用して、指定された属性値を現在実行中のシステムの対応する値と比較します。 dwTypeBitMask が VER_SUITENAME 以外のすべての値の場合、このパラメーターには次の値のいずれかを指定できます。
dwTypeBitMask が VER_SUITENAME の場合、このパラメーターには次の値のいずれかを指定できます。
|
戻り値の型: ULONGLONG
公式ドキュメント
指定したオペレーティングシステムのバージョン属性に対して使用する比較演算子を示すように、64 ビット値のビットを設定します。この関数は、VerifyVersionInfo 関数の dwlConditionMask パラメーターを構築するために使用します。
戻り値
この関数は条件マスク値を返します。
解説(Remarks)
VerifyVersionInfo 関数の dwTypeMask パラメーターで設定されているビットごとに、この関数を 1 回ずつ呼び出します。
例
例については、Verifying the System Version を参照してください。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
ULONGLONG VerSetConditionMask(
ULONGLONG ConditionMask,
VER_FLAGS TypeMask,
BYTE Condition
);[DllImport("KERNEL32.dll", ExactSpelling = true)]
static extern ulong VerSetConditionMask(
ulong ConditionMask, // ULONGLONG
uint TypeMask, // VER_FLAGS
byte Condition // BYTE
);<DllImport("KERNEL32.dll", ExactSpelling:=True)>
Public Shared Function VerSetConditionMask(
ConditionMask As ULong, ' ULONGLONG
TypeMask As UInteger, ' VER_FLAGS
Condition As Byte ' BYTE
) As ULong
End Function' ConditionMask : ULONGLONG
' TypeMask : VER_FLAGS
' Condition : BYTE
Declare PtrSafe Function VerSetConditionMask Lib "kernel32" ( _
ByVal ConditionMask As LongLong, _
ByVal TypeMask As Long, _
ByVal Condition As Byte) As LongLong
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
VerSetConditionMask = ctypes.windll.kernel32.VerSetConditionMask
VerSetConditionMask.restype = ctypes.c_ulonglong
VerSetConditionMask.argtypes = [
ctypes.c_ulonglong, # ConditionMask : ULONGLONG
wintypes.DWORD, # TypeMask : VER_FLAGS
ctypes.c_ubyte, # Condition : BYTE
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
VerSetConditionMask = Fiddle::Function.new(
lib['VerSetConditionMask'],
[
-Fiddle::TYPE_LONG_LONG, # ConditionMask : ULONGLONG
-Fiddle::TYPE_INT, # TypeMask : VER_FLAGS
-Fiddle::TYPE_CHAR, # Condition : BYTE
],
-Fiddle::TYPE_LONG_LONG)#[link(name = "kernel32")]
extern "system" {
fn VerSetConditionMask(
ConditionMask: u64, // ULONGLONG
TypeMask: u32, // VER_FLAGS
Condition: u8 // BYTE
) -> u64;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("KERNEL32.dll")]
public static extern ulong VerSetConditionMask(ulong ConditionMask, uint TypeMask, byte Condition);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_VerSetConditionMask' -Namespace Win32 -PassThru
# $api::VerSetConditionMask(ConditionMask, TypeMask, Condition)#uselib "KERNEL32.dll"
#func global VerSetConditionMask "VerSetConditionMask" sptr, sptr, sptr
; VerSetConditionMask ConditionMask, TypeMask, Condition ; 戻り値は stat
; ConditionMask : ULONGLONG -> "sptr"
; TypeMask : VER_FLAGS -> "sptr"
; Condition : BYTE -> "sptr"
; ※HSP3.7は int64 引数(64bit値渡し)に非対応です。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "KERNEL32.dll"
#cfunc global VerSetConditionMask "VerSetConditionMask" int64, int, int
; res = VerSetConditionMask(ConditionMask, TypeMask, Condition)
; ConditionMask : ULONGLONG -> "int64"
; TypeMask : VER_FLAGS -> "int"
; Condition : BYTE -> "int"
; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。; ULONGLONG VerSetConditionMask(ULONGLONG ConditionMask, VER_FLAGS TypeMask, BYTE Condition)
#uselib "KERNEL32.dll"
#cfunc global VerSetConditionMask "VerSetConditionMask" int64, int, int
; res = VerSetConditionMask(ConditionMask, TypeMask, Condition)
; ConditionMask : ULONGLONG -> "int64"
; TypeMask : VER_FLAGS -> "int"
; Condition : BYTE -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procVerSetConditionMask = kernel32.NewProc("VerSetConditionMask")
)
// ConditionMask (ULONGLONG), TypeMask (VER_FLAGS), Condition (BYTE)
r1, _, err := procVerSetConditionMask.Call(
uintptr(ConditionMask),
uintptr(TypeMask),
uintptr(Condition),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // ULONGLONGfunction VerSetConditionMask(
ConditionMask: UInt64; // ULONGLONG
TypeMask: DWORD; // VER_FLAGS
Condition: Byte // BYTE
): UInt64; stdcall;
external 'KERNEL32.dll' name 'VerSetConditionMask';result := DllCall("KERNEL32\VerSetConditionMask"
, "Int64", ConditionMask ; ULONGLONG
, "UInt", TypeMask ; VER_FLAGS
, "UChar", Condition ; BYTE
, "Int64") ; return: ULONGLONG●VerSetConditionMask(ConditionMask, TypeMask, Condition) = DLL("KERNEL32.dll", "qword VerSetConditionMask(qword, dword, byte)")
# 呼び出し: VerSetConditionMask(ConditionMask, TypeMask, Condition)
# ConditionMask : ULONGLONG -> "qword"
# TypeMask : VER_FLAGS -> "dword"
# Condition : BYTE -> "byte"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "kernel32" fn VerSetConditionMask(
ConditionMask: u64, // ULONGLONG
TypeMask: u32, // VER_FLAGS
Condition: u8 // BYTE
) callconv(std.os.windows.WINAPI) u64;proc VerSetConditionMask(
ConditionMask: uint64, # ULONGLONG
TypeMask: uint32, # VER_FLAGS
Condition: uint8 # BYTE
): uint64 {.importc: "VerSetConditionMask", stdcall, dynlib: "KERNEL32.dll".}pragma(lib, "kernel32");
extern(Windows)
ulong VerSetConditionMask(
ulong ConditionMask, // ULONGLONG
uint TypeMask, // VER_FLAGS
ubyte Condition // BYTE
);ccall((:VerSetConditionMask, "KERNEL32.dll"), stdcall, UInt64,
(UInt64, UInt32, UInt8),
ConditionMask, TypeMask, Condition)
# ConditionMask : ULONGLONG -> UInt64
# TypeMask : VER_FLAGS -> UInt32
# Condition : BYTE -> UInt8
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint64_t VerSetConditionMask(
uint64_t ConditionMask,
uint32_t TypeMask,
uint8_t Condition);
]]
local kernel32 = ffi.load("kernel32")
-- kernel32.VerSetConditionMask(ConditionMask, TypeMask, Condition)
-- ConditionMask : ULONGLONG
-- TypeMask : VER_FLAGS
-- Condition : BYTE
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('KERNEL32.dll');
const VerSetConditionMask = lib.func('__stdcall', 'VerSetConditionMask', 'uint64_t', ['uint64_t', 'uint32_t', 'uint8_t']);
// VerSetConditionMask(ConditionMask, TypeMask, Condition)
// ConditionMask : ULONGLONG -> 'uint64_t'
// TypeMask : VER_FLAGS -> 'uint32_t'
// Condition : BYTE -> 'uint8_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("KERNEL32.dll", {
VerSetConditionMask: { parameters: ["u64", "u32", "u8"], result: "u64" },
});
// lib.symbols.VerSetConditionMask(ConditionMask, TypeMask, Condition)
// ConditionMask : ULONGLONG -> "u64"
// TypeMask : VER_FLAGS -> "u32"
// Condition : BYTE -> "u8"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint64_t VerSetConditionMask(
uint64_t ConditionMask,
uint32_t TypeMask,
uint8_t Condition);
C, "KERNEL32.dll");
// $ffi->VerSetConditionMask(ConditionMask, TypeMask, Condition);
// ConditionMask : ULONGLONG
// TypeMask : VER_FLAGS
// Condition : BYTE
// 構造体/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 Kernel32 extends StdCallLibrary {
Kernel32 INSTANCE = Native.load("kernel32", Kernel32.class);
long VerSetConditionMask(
long ConditionMask, // ULONGLONG
int TypeMask, // VER_FLAGS
byte Condition // BYTE
);
}@[Link("kernel32")]
lib LibKERNEL32
fun VerSetConditionMask = VerSetConditionMask(
ConditionMask : UInt64, # ULONGLONG
TypeMask : UInt32, # VER_FLAGS
Condition : UInt8 # BYTE
) : UInt64
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef VerSetConditionMaskNative = Uint64 Function(Uint64, Uint32, Uint8);
typedef VerSetConditionMaskDart = int Function(int, int, int);
final VerSetConditionMask = DynamicLibrary.open('KERNEL32.dll')
.lookupFunction<VerSetConditionMaskNative, VerSetConditionMaskDart>('VerSetConditionMask');
// ConditionMask : ULONGLONG -> Uint64
// TypeMask : VER_FLAGS -> Uint32
// Condition : BYTE -> Uint8
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function VerSetConditionMask(
ConditionMask: UInt64; // ULONGLONG
TypeMask: DWORD; // VER_FLAGS
Condition: Byte // BYTE
): UInt64; stdcall;
external 'KERNEL32.dll' name 'VerSetConditionMask';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "VerSetConditionMask"
c_VerSetConditionMask :: Word64 -> Word32 -> Word8 -> IO Word64
-- ConditionMask : ULONGLONG -> Word64
-- TypeMask : VER_FLAGS -> Word32
-- Condition : BYTE -> Word8
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let versetconditionmask =
foreign "VerSetConditionMask"
(uint64_t @-> uint32_t @-> uint8_t @-> returning uint64_t)
(* ConditionMask : ULONGLONG -> uint64_t *)
(* TypeMask : VER_FLAGS -> uint32_t *)
(* Condition : BYTE -> uint8_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library kernel32 (t "KERNEL32.dll"))
(cffi:use-foreign-library kernel32)
(cffi:defcfun ("VerSetConditionMask" ver-set-condition-mask :convention :stdcall) :uint64
(condition-mask :uint64) ; ULONGLONG
(type-mask :uint32) ; VER_FLAGS
(condition :uint8)) ; BYTE
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $VerSetConditionMask = Win32::API::More->new('KERNEL32',
'UINT64 VerSetConditionMask(UINT64 ConditionMask, DWORD TypeMask, BYTE Condition)');
# my $ret = $VerSetConditionMask->Call($ConditionMask, $TypeMask, $Condition);
# ConditionMask : ULONGLONG -> UINT64
# TypeMask : VER_FLAGS -> DWORD
# Condition : BYTE -> BYTE
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
- s OSVERSIONINFOEXW
- f VerifyVersionInfoW — 指定条件でOSのバージョン情報を検証する(Unicode版)。