在 C# 的 Windows-CE 中,您如何告诉您 运行 所在的体系结构?
How do you tell the architecture you're running on in Windows-CE in C#?
我正在为 运行 多个设备上的 WEC7 应用程序编写安装程序,每个设备具有不同的体系结构,甚至可能有不同的 OS 版本。由于历史原因,该应用程序是用 C++ 编写的。这意味着该应用程序是针对每个 OS/architecture 版本编译的。安装程序包具有所有版本作为资源。我只需要弄清楚要安装哪个。 OS 版本可以在 System.Environment.OSVersion.Version.Major,但我分不清 ARM 和 x86 架构之间的区别。
我运行可能的解决方案包括:
SYSTEM_INFO si;
GetSystemInfo(&si);
return si.wProcessorArchitecture;
但是,那是 C++ 代码,因此存在同样的问题,即:两个编译版本(ARM 和 x86),您必须知道要加载哪个...但这就是我想要 运行代码。
我也调查过System.Management
,但我找不到WEC7上的那个。
有什么建议吗?
您总是可以 P/Invoke GetSystemInfo
调用:
[DllImport("coredll.dll")]
public static extern void GetSystemInfo(out SystemInfo info);
public enum ProcessorArchitecture
{
Intel = 0,
Mips = 1,
Shx = 4,
Arm = 5,
Unknown = 0xFFFF,
}
[StructLayout(LayoutKind.Sequential)]
public struct SystemInfo
{
public ProcessorArchitecture ProcessorArchitecture;
public uint PageSize;
public IntPtr MinimumApplicationAddress;
public IntPtr MaximumApplicationAddress;
public IntPtr ActiveProcessorMask;
public uint NumberOfProcessors;
public uint ProcessorType;
public uint AllocationGranularity;
public ushort ProcessorLevel;
public ushort ProcessorRevision;
}
我正在为 运行 多个设备上的 WEC7 应用程序编写安装程序,每个设备具有不同的体系结构,甚至可能有不同的 OS 版本。由于历史原因,该应用程序是用 C++ 编写的。这意味着该应用程序是针对每个 OS/architecture 版本编译的。安装程序包具有所有版本作为资源。我只需要弄清楚要安装哪个。 OS 版本可以在 System.Environment.OSVersion.Version.Major,但我分不清 ARM 和 x86 架构之间的区别。
我运行可能的解决方案包括:
SYSTEM_INFO si;
GetSystemInfo(&si);
return si.wProcessorArchitecture;
但是,那是 C++ 代码,因此存在同样的问题,即:两个编译版本(ARM 和 x86),您必须知道要加载哪个...但这就是我想要 运行代码。
我也调查过System.Management
,但我找不到WEC7上的那个。
有什么建议吗?
您总是可以 P/Invoke GetSystemInfo
调用:
[DllImport("coredll.dll")]
public static extern void GetSystemInfo(out SystemInfo info);
public enum ProcessorArchitecture
{
Intel = 0,
Mips = 1,
Shx = 4,
Arm = 5,
Unknown = 0xFFFF,
}
[StructLayout(LayoutKind.Sequential)]
public struct SystemInfo
{
public ProcessorArchitecture ProcessorArchitecture;
public uint PageSize;
public IntPtr MinimumApplicationAddress;
public IntPtr MaximumApplicationAddress;
public IntPtr ActiveProcessorMask;
public uint NumberOfProcessors;
public uint ProcessorType;
public uint AllocationGranularity;
public ushort ProcessorLevel;
public ushort ProcessorRevision;
}