PortableExecutableKinds : PortableExecutableKinds : Assembly C# Examples


C# Examples » Assembly » PortableExecutableKinds »

 

PortableExecutableKinds









    
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;
                        }
                }  
        }
}
    
   
  
   



Output

main, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null: ILOnly...I386
platform independent


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Assembly
» PortableExecutableKinds