如何在 C# 代码中获取操作系统详细信息
我需要获取 OsArchitecture 意味着 O/s 的位,我使用 Win32_OperatingSystem 但它的“OsArchitecture”不适用于所有类型的操作系统
ManagementObjectSearcher objOSDetails = new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem");
ManagementObjectCollection osDetailsCollection = objOSDetails.Get();
foreach( ManagementObject mo in osDetailsCollection )
{
String _operatingSysBits = mo["OSArchitecture"].ToString();
}
i need to get OsArchitecture means Bits of O/s , i used Win32_OperatingSystem but its "OsArchitecture "is not work for all type Operating System
ManagementObjectSearcher objOSDetails = new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem");
ManagementObjectCollection osDetailsCollection = objOSDetails.Get();
foreach( ManagementObject mo in osDetailsCollection )
{
String _operatingSysBits = mo["OSArchitecture"].ToString();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
检查IntPtr.Size。在 32 位平台上为 4,在 64 位平台上为 8(除非您的进程在 32 位模式下运行)。
Check IntPtr.Size. It will be 4 on a 32-bit platform, and 8 on a 64-bit platform (unless your process is running in 32bit mode).
对于.NET 4.0,有Environment.is64BitOperatingSystem
或
for .NET 4.0 there is Environment.is64BitOperatingSystem
or