Welcome to MSDN Blogs Sign in | Join | Help

Determine the processorArchitecture of the running process from managed code

I discussed Figure out the bitness of a process and the ProcessorArchicture of the system back in July 2005.

If you just want to determine the processorArchitecture of the running process from managed code, there is an easier way in .Net framework 2.0.

C:\temp>more test.cs

using System;

using System.Reflection;

 

public class test

{

    public static void Main()

    {

        Console.WriteLine(typeof(System.Object).Assembly.GetName().ProcessorArchitecture);

    }

}

 

C:\temp>test

Amd64

This takes advantage of the fact that mscorlib.dll is a platform specific assembly in .Net framework v2.0.

Published Tuesday, March 14, 2006 8:00 AM by junfeng
Filed under:

Comments

# re: Determine the processorArchitecture of the running process from managed code

Tuesday, March 14, 2006 11:07 AM by jmstall
Great tip. It looks like this saves me a pinvoke to kernel32!GetSystemInfo.

# re: Determine the processorArchitecture of the running process from managed code

Tuesday, March 14, 2006 12:07 PM by oldnewthing
But that's an implementation detail. Maybe in the next version 3 of the framework, System.Object will be in a neutral assembly. Don't rely on undocument side effects. Do it the right way.

# re: Determine the processorArchitecture of the running process from managed code

Thursday, June 01, 2006 6:24 PM by rape stories
Best of the text i read about a problem.
New Comments to this post are disabled
 
Page view tracker