[Programming] Determine whether a specified processor feature is supported by the current computer

To determine whether a specified processor feature is supported by the current computer, use IsProcessorFeaturePresent function found in kernel32.dll.

Syntax:

BOOL IsProcessorFeaturePresent(
  [in] DWORD ProcessorFeature
);

For parameter value, you can refer to Win32 API documentation.


C# (.NET Framework 4.7.2)

using System;
using System.Runtime.InteropServices;
namespace CPU
{
    internal class Program
    {
        [DllImport("kernel32.dll")]
        private static extern bool IsProcessorFeaturePresent(uint ProcessorFeature);
        static void Main(string[] args)
        {
            Console.WriteLine("PF_SSSE3_INSTRUCTIONS_AVAILABLE " + IsProcessorFeaturePresent(36));
            Console.WriteLine("PF_AVX_INSTRUCTIONS_AVAILABLE " + IsProcessorFeaturePresent(39));
            Console.ReadLine();
        }
    }
}

Output:

PF_SSSE3_INSTRUCTIONS_AVAILABLE True
PF_AVX_INSTRUCTIONS_AVAILABLE False

For other generic processor information, you can always populate it through Win32_Processor WMI class in System.Management assembly.

Comments

Popular posts from this blog

[Badminton] Viktor Axelsen stunned by Thai rising star in India Open 2023