PortableExecutableKinds : PortableExecutableKinds « Assembly « C# / CSharp Tutorial






using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Reflection;
using System.Reflection.Emit;

public class MainClass
{
    public static void Main()
    {
        Assembly a = Assembly.GetExecutingAssembly();
        Module m = a.ManifestModule;

        PortableExecutableKinds peKinds;
        ImageFileMachine imageFileMachine;
        m.GetPEKind(out peKinds, out imageFileMachine);

        Console.WriteLine("{0}: {1}...{2}", a.FullName, peKinds, imageFileMachine);

        if ((peKinds & PortableExecutableKinds.ILOnly) != 0)
        {
            Console.WriteLine("platform independent");
        }
        else
        {
            Console.WriteLine("platform dependent");
            switch (imageFileMachine)
            {
                case ImageFileMachine.I386:
                    Console.WriteLine("I386");
                    break;
                case ImageFileMachine.IA64:
                    Console.WriteLine("IA64");
                    break;
                case ImageFileMachine.AMD64:
                    Console.WriteLine("AMD64");
                    break;
            }
        } 
    }
}
main, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null: ILOnly...I386
platform independent








12.7.PortableExecutableKinds
12.7.1.PortableExecutableKinds