MSDN.WhiteKnight - Stack Overflow answers
Ответ на "C# Как узнать разрядности чужого exe или чужого процесса?"
Answer 765818
Для EXE-файла можно узнать разрядность с помощью функции GetBinaryType
using System; using System.Runtime.InteropServices; public enum BinaryType : uint { SCS_32BIT_BINARY = 0, SCS_64BIT_BINARY = 6, SCS_DOS_BINARY = 1, SCS_OS216_BINARY = 5, SCS_PIF_BINARY = 3, SCS_POSIX_BINARY = 4, SCS_WOW_BINARY = 2 } public class MyClass { [DllImport("kernel32.dll")] public static extern bool GetBinaryType(string lpApplicationName, out BinaryType lpBinaryType); void PrintExeType(string ExeFilePath) { BinaryType bt; bool res = Native.GetBinaryType(ExeFilePath, out bt); if (res == false) MessageBox.Show("Not executable"); else { switch (bt) { case BinaryType.SCS_32BIT_BINARY: MessageBox.Show("32-bit executable"); break; case BinaryType.SCS_64BIT_BINARY: MessageBox.Show("64-bit executable"); break; default: MessageBox.Show("Other executable"); break; } } } }
Content is retrieved from StackExchange API.
Auto-generated by ruso-archive tools.