IsProcessorFeaturePresent
関数シグネチャ
// KERNEL32.dll
#include <windows.h>
BOOL IsProcessorFeaturePresent(
PROCESSOR_FEATURE_ID ProcessorFeature
);パラメーター
| 名前 | 型 | 方向 | 説明 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ProcessorFeature | PROCESSOR_FEATURE_ID | in | テスト対象のプロセッサ機能。このパラメーターには、次のいずれかの値を指定できます。
|
戻り値の型: BOOL
公式ドキュメント
指定されたプロセッサ機能が現在のコンピューターでサポートされているかどうかを判定します。
戻り値
機能がサポートされている場合、戻り値は非ゼロの値です。
機能がサポートされていない場合、戻り値はゼロです。
HAL が機能の検出をサポートしていない場合、ハードウェアがその機能をサポートしているかどうかにかかわらず、戻り値も同様にゼロになります。
解説(Remarks)
PF_SSSE3_INSTRUCTIONS_AVAILABLE から PF_AVX512F_INSTRUCTIONS_AVAILABLE までのサポートは Windows SDK (19041) で追加され、Windows 10 バージョン 2004 (May 2020 Update) 以降でサポートされます。
PF_ERMS_AVAILABLE、PF_ARM_V82_DP_INSTRUCTIONS_AVAILABLE、および PF_ARM_V83_JSCVT_INSTRUCTIONS_AVAILABLE のサポートは Windows SDK (20348) で追加され、Windows 11 および Windows Server 2022 でサポートされます。
PF_ARM_V83_LRCPC_INSTRUCTIONS_AVAILABLE の定義は Windows SDK (22621) で追加され、Windows 11 バージョン 22H2 でサポートされます。
PF_ARM_SVE_INSTRUCTIONS_AVAILABLE から PF_MOVDIR64B_INSTRUCTION_AVAILABLE まで、および PF_ARM_SHA3_INSTRUCTIONS_AVAILABLE から PF_ARM_V86_EBF16_INSTRUCTIONS_AVAILABLE までのサポートは Windows SDK (26100) で追加され、Windows 11 バージョン 24H2 および Windows Server 2025 以降でサポートされます。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
BOOL IsProcessorFeaturePresent(
PROCESSOR_FEATURE_ID ProcessorFeature
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", ExactSpelling = true)]
static extern bool IsProcessorFeaturePresent(
uint ProcessorFeature // PROCESSOR_FEATURE_ID
);<DllImport("KERNEL32.dll", ExactSpelling:=True)>
Public Shared Function IsProcessorFeaturePresent(
ProcessorFeature As UInteger ' PROCESSOR_FEATURE_ID
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' ProcessorFeature : PROCESSOR_FEATURE_ID
Declare PtrSafe Function IsProcessorFeaturePresent Lib "kernel32" ( _
ByVal ProcessorFeature As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
IsProcessorFeaturePresent = ctypes.windll.kernel32.IsProcessorFeaturePresent
IsProcessorFeaturePresent.restype = wintypes.BOOL
IsProcessorFeaturePresent.argtypes = [
wintypes.DWORD, # ProcessorFeature : PROCESSOR_FEATURE_ID
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
IsProcessorFeaturePresent = Fiddle::Function.new(
lib['IsProcessorFeaturePresent'],
[
-Fiddle::TYPE_INT, # ProcessorFeature : PROCESSOR_FEATURE_ID
],
Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn IsProcessorFeaturePresent(
ProcessorFeature: u32 // PROCESSOR_FEATURE_ID
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll")]
public static extern bool IsProcessorFeaturePresent(uint ProcessorFeature);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_IsProcessorFeaturePresent' -Namespace Win32 -PassThru
# $api::IsProcessorFeaturePresent(ProcessorFeature)#uselib "KERNEL32.dll"
#func global IsProcessorFeaturePresent "IsProcessorFeaturePresent" sptr
; IsProcessorFeaturePresent ProcessorFeature ; 戻り値は stat
; ProcessorFeature : PROCESSOR_FEATURE_ID -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "KERNEL32.dll"
#cfunc global IsProcessorFeaturePresent "IsProcessorFeaturePresent" int
; res = IsProcessorFeaturePresent(ProcessorFeature)
; ProcessorFeature : PROCESSOR_FEATURE_ID -> "int"; BOOL IsProcessorFeaturePresent(PROCESSOR_FEATURE_ID ProcessorFeature)
#uselib "KERNEL32.dll"
#cfunc global IsProcessorFeaturePresent "IsProcessorFeaturePresent" int
; res = IsProcessorFeaturePresent(ProcessorFeature)
; ProcessorFeature : PROCESSOR_FEATURE_ID -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procIsProcessorFeaturePresent = kernel32.NewProc("IsProcessorFeaturePresent")
)
// ProcessorFeature (PROCESSOR_FEATURE_ID)
r1, _, err := procIsProcessorFeaturePresent.Call(
uintptr(ProcessorFeature),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction IsProcessorFeaturePresent(
ProcessorFeature: DWORD // PROCESSOR_FEATURE_ID
): BOOL; stdcall;
external 'KERNEL32.dll' name 'IsProcessorFeaturePresent';result := DllCall("KERNEL32\IsProcessorFeaturePresent"
, "UInt", ProcessorFeature ; PROCESSOR_FEATURE_ID
, "Int") ; return: BOOL●IsProcessorFeaturePresent(ProcessorFeature) = DLL("KERNEL32.dll", "bool IsProcessorFeaturePresent(dword)")
# 呼び出し: IsProcessorFeaturePresent(ProcessorFeature)
# ProcessorFeature : PROCESSOR_FEATURE_ID -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "kernel32" fn IsProcessorFeaturePresent(
ProcessorFeature: u32 // PROCESSOR_FEATURE_ID
) callconv(std.os.windows.WINAPI) i32;proc IsProcessorFeaturePresent(
ProcessorFeature: uint32 # PROCESSOR_FEATURE_ID
): int32 {.importc: "IsProcessorFeaturePresent", stdcall, dynlib: "KERNEL32.dll".}pragma(lib, "kernel32");
extern(Windows)
int IsProcessorFeaturePresent(
uint ProcessorFeature // PROCESSOR_FEATURE_ID
);ccall((:IsProcessorFeaturePresent, "KERNEL32.dll"), stdcall, Int32,
(UInt32,),
ProcessorFeature)
# ProcessorFeature : PROCESSOR_FEATURE_ID -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t IsProcessorFeaturePresent(
uint32_t ProcessorFeature);
]]
local kernel32 = ffi.load("kernel32")
-- kernel32.IsProcessorFeaturePresent(ProcessorFeature)
-- ProcessorFeature : PROCESSOR_FEATURE_ID
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('KERNEL32.dll');
const IsProcessorFeaturePresent = lib.func('__stdcall', 'IsProcessorFeaturePresent', 'int32_t', ['uint32_t']);
// IsProcessorFeaturePresent(ProcessorFeature)
// ProcessorFeature : PROCESSOR_FEATURE_ID -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("KERNEL32.dll", {
IsProcessorFeaturePresent: { parameters: ["u32"], result: "i32" },
});
// lib.symbols.IsProcessorFeaturePresent(ProcessorFeature)
// ProcessorFeature : PROCESSOR_FEATURE_ID -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t IsProcessorFeaturePresent(
uint32_t ProcessorFeature);
C, "KERNEL32.dll");
// $ffi->IsProcessorFeaturePresent(ProcessorFeature);
// ProcessorFeature : PROCESSOR_FEATURE_ID
// 構造体/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);
boolean IsProcessorFeaturePresent(
int ProcessorFeature // PROCESSOR_FEATURE_ID
);
}@[Link("kernel32")]
lib LibKERNEL32
fun IsProcessorFeaturePresent = IsProcessorFeaturePresent(
ProcessorFeature : UInt32 # PROCESSOR_FEATURE_ID
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef IsProcessorFeaturePresentNative = Int32 Function(Uint32);
typedef IsProcessorFeaturePresentDart = int Function(int);
final IsProcessorFeaturePresent = DynamicLibrary.open('KERNEL32.dll')
.lookupFunction<IsProcessorFeaturePresentNative, IsProcessorFeaturePresentDart>('IsProcessorFeaturePresent');
// ProcessorFeature : PROCESSOR_FEATURE_ID -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function IsProcessorFeaturePresent(
ProcessorFeature: DWORD // PROCESSOR_FEATURE_ID
): BOOL; stdcall;
external 'KERNEL32.dll' name 'IsProcessorFeaturePresent';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "IsProcessorFeaturePresent"
c_IsProcessorFeaturePresent :: Word32 -> IO CInt
-- ProcessorFeature : PROCESSOR_FEATURE_ID -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let isprocessorfeaturepresent =
foreign "IsProcessorFeaturePresent"
(uint32_t @-> returning int32_t)
(* ProcessorFeature : PROCESSOR_FEATURE_ID -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library kernel32 (t "KERNEL32.dll"))
(cffi:use-foreign-library kernel32)
(cffi:defcfun ("IsProcessorFeaturePresent" is-processor-feature-present :convention :stdcall) :int32
(processor-feature :uint32)) ; PROCESSOR_FEATURE_ID
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $IsProcessorFeaturePresent = Win32::API::More->new('KERNEL32',
'BOOL IsProcessorFeaturePresent(DWORD ProcessorFeature)');
# my $ret = $IsProcessorFeaturePresent->Call($ProcessorFeature);
# ProcessorFeature : PROCESSOR_FEATURE_ID -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。