基础OS体系结构 [英] Underlying OS architecture

查看:103
本文介绍了基础OS体系结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


最近有一个关于如何判断安装版本的

Windows是32位还是64位的线程,但是这似乎从我的

新闻阅读器中消失了,所以为开始一个新线程道歉。


无论如何,第一个建议是使用IntPtr.Size。这显然是错误的,

因为这只会告诉你*你的*应用程序*是32位还是64位

例如


32位操作系统上的32位应用程序 - IntPtr.Size = 4

64位操作系统上的64位应用程序 - IntPtr.Size = 8

32 64位操作系统上的-bit应用程序 - IntPtr.Size = 4

这样就没用了,类似的API调用对于
$似乎也不可靠b $ b同样的原因。

第二个建议是使用WMI,特别是System.Management命名空间中Win32_OperatingSystem类的OSArchitecture值



的问题在于它仅在Vista中可用 -
http://msdn2.microsoft.com/En-US/library/aa394239.aspx 这使得它几乎比无用的更糟糕。


[还有评论说没人真正需要知道这些信息

无论如何,这可能是真的,但并没有提供解决方案。 ]


我能找到的唯一方法是:


1)找到安装Windows的驱动器号(来自WMI)


2)添加:\\Program Files(x86)对它来说


3)查看结果文件夹是否存在Directory.Exists


这显然非常糟糕但是最可靠的方法我到目前为止已经找到了




有人能建议更好的方式吗?


谢谢,

DJ

Hello,

There was a thread recently about how to tell if the installed version of
Windows is 32-bit or 64-bit, but that seems to have disappeared from my
newsreader so apologies for starting a new thread.

Anyway, the first suggestion was to use IntPtr.Size. That is clearly wrong,
because that will only tell you if your *application* is 32-bit or 64-bit
e.g.

32-bit app on 32-bit OS - IntPtr.Size = 4
64-bit app on 64-bit OS - IntPtr.Size = 8
32-bit app on 64-bit OS - IntPtr.Size = 4

so that''s no use, and similar API calls also seem to be unreliable for the
same reason.

The second suggestion was to use WMI, specifically the OSArchitecture value
of the Win32_OperatingSystem class in the System.Management namespace. The
problem with that is that it is available only in Vista -
http://msdn2.microsoft.com/En-US/library/aa394239.aspx which makes it almost
worse than useless.

[There was also a comment that nobody really needs to know this information
anyway, which may be true, but doesn''t provide a solution.]

The only way that I can find to do this is:

1) find the drive letter that Windows is installed on (from WMI)

2) add ":\\Program Files (x86)" to it

3) see if the resulting folder exists with Directory.Exists

This is fairly obviously pretty awful but is the most reliable method I have
found so far.

Can anyone suggest a better way?

Thanks,

DJ

推荐答案

大卫,


我很好奇,什么是你正在努力做到的?为什么你需要知道操作系统是64位而不是你的应用程序运行的模式是什么?

-

- Nicholas Paldino [.NET / C#MVP]

- mv * @ spam .guard.caspershouse.com


" David Jackson" < so ***** @ somewhere.comwrote in message

news:uC ************** @ TK2MSFTNGP02.phx.gbl ...
David,

I am curious, what is it that you are trying to do exactly? Why do you
need to know whether the OS is 64 bit as opposed to the mode under which
your app is running?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"David Jackson" <so*****@somewhere.comwrote in message
news:uC**************@TK2MSFTNGP02.phx.gbl...

你好,


最近有一个关于如何判断

的安装版本的帖子Windows是32位或64位,但这似乎从我的

新闻阅读器中消失了,所以对于开始一个新主题道歉。


无论如何,第一个建议是使用IntPtr.Size。这显然是错误的,因为这只会告诉你你的*应用程序*是32位还是

64位例如


32位操作系统上的32位应用程序 - IntPtr.Size = 4

64位操作系统上的64位应用程序 - IntPtr.Size = 8

32 64位操作系统上的-bit应用程序 - IntPtr.Size = 4

这样就没用了,类似的API调用对于
$似乎也不可靠b $ b同样的原因。

第二个建议是使用WMI,特别是System.Management中的Win32_OperatingSystem类的OSArchitecture


命名空间。问题在于它仅在Vista中可用 -
http://msdn2.microsoft.com/En-US/library/aa394239.aspx 这使得它比无用的更糟糕。


[还有评论说没人真正需要知道这个

信息,这可能是真的,但是没有提供解决方案。]

我能找到的唯一方法是:


1)找到安装Windows的驱动器号(来自WMI)


2)添加":\\Program Files(x86)"对它来说


3)查看结果文件夹是否存在Directory.Exists


这显然非常糟糕但是最可靠的方法到目前为止我已经找到了



有人能建议更好的方式吗?


谢谢,

DJ
Hello,

There was a thread recently about how to tell if the installed version of
Windows is 32-bit or 64-bit, but that seems to have disappeared from my
newsreader so apologies for starting a new thread.

Anyway, the first suggestion was to use IntPtr.Size. That is clearly
wrong, because that will only tell you if your *application* is 32-bit or
64-bit e.g.

32-bit app on 32-bit OS - IntPtr.Size = 4
64-bit app on 64-bit OS - IntPtr.Size = 8
32-bit app on 64-bit OS - IntPtr.Size = 4

so that''s no use, and similar API calls also seem to be unreliable for the
same reason.

The second suggestion was to use WMI, specifically the OSArchitecture
value of the Win32_OperatingSystem class in the System.Management
namespace. The problem with that is that it is available only in Vista -
http://msdn2.microsoft.com/En-US/library/aa394239.aspx which makes it
almost worse than useless.

[There was also a comment that nobody really needs to know this
information anyway, which may be true, but doesn''t provide a solution.]

The only way that I can find to do this is:

1) find the drive letter that Windows is installed on (from WMI)

2) add ":\\Program Files (x86)" to it

3) see if the resulting folder exists with Directory.Exists

This is fairly obviously pretty awful but is the most reliable method I
have found so far.

Can anyone suggest a better way?

Thanks,

DJ



6月19日下午4:41,David Jackson < some ... @ somewhere.comwrote:
On Jun 19, 4:41 pm, "David Jackson" <some...@somewhere.comwrote:

我能找到的唯一方法就是:


1)找到安装Windows的驱动器号(来自WMI)


2)添加:\\Program Files(x86)对它来说


3)查看结果文件夹是否存在Directory.Exists


这显然非常糟糕但是最可靠的方法到目前为止我找到了

The only way that I can find to do this is:

1) find the drive letter that Windows is installed on (from WMI)

2) add ":\\Program Files (x86)" to it

3) see if the resulting folder exists with Directory.Exists

This is fairly obviously pretty awful but is the most reliable method I have
found so far.



不幸的是我没有给你一个解决方案,但我只是想

请注意,这会因非英语而失败Windows版本。

Matt

Unfortunately I don''t have a solution for you, but I just wanted to
note that this would fail on non-English builds of Windows.
Matt


" Nicholas Paldino [.NET / C#MVP]" < mv*@spam.guard.caspershouse.com写在

消息新闻:在**************** @ TK2MSFTNGP02.phx.gbl ...
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote in
message news:On****************@TK2MSFTNGP02.phx.gbl...

我很好奇,你究竟要做的是什么?
I am curious, what is it that you are trying to do exactly?



了解我的应用程序是在32位还是64位Windows上运行。

Find out whether my app is running on 32-bit or 64-bit Windows.


为什么你需要知道操作系统是64位
Why do you need to know whether the OS is 64 bit



这实际上是否重要......?这会阻止你帮助我......?

Does that actually matter...? Does that prevent you from helping me...?


这篇关于基础OS体系结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆