Identifying the CPU architecture type using C#

前端 未结 14 2273
心在旅途
心在旅途 2020-12-01 17:52

I want to check which CPU architecture is the user running, is it i386 or X64 or AMD64. I want to do it in C#. I know i can try WMI or Registry. Is there any other way apart

14条回答
  •  遥遥无期
    2020-12-01 18:52

    I know that this question is from the past, but as of 2017, there is now a simple method to know the architecture of the current process, in .net standard :

    System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture
    

    The value returned is one of X86, X64, ARM, ARM64 and gives the architecture of the process it's running in. OSArchitecture returns the architecture of the installed operating system instead.

    Links to the docs (pretty useless though...):

    RuntimeInformation.ProcessArchitecture: https://docs.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.runtimeinformation.processarchitecture?view=netstandard-1.4

    Architecture enumeration: https://docs.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.architecture?view=netstandard-1.4

提交回复
热议问题