将Windows确定为32位或64位

时间:2014-07-06 16:39:23

标签: x86 64-bit autoit cpu-architecture

这是我到目前为止的代码:

#include <MsgBoxConstants.au3>
If FileExists(@HomeDrive & "Program Files (x86)") Then
   $arc = 64
Else
   $arc = 32
EndIf
MsgBox("Hello", "Bit", "The computer that the program is been run on is a " & $arc & "bit one.")

当它是64时,它会说我的电脑是32位。所以我查看了路径并制作了新代码:

#include <MsgBoxConstants.au3>
If FileExists(@HomeDrive & "Program Files (x86)") Then
   $arc = 64
Else
   $arc = 32
EndIf
$path = @HomeDrive & "\Program Files (x86)"
MsgBox("Hello", $path, "The computer that the program is been run on is a " & $arc & "bit one.")

这显示了路径,似乎没问题。我哪里错了?

3 个答案:

答案 0 :(得分:1)

您需要阅读@OSArch宏。

  

返回以下内容之一:&#34; X86&#34;,&#34; IA64&#34;,&#34; X64&#34; - 这是当前运行的操作系统的体系结构类型。

答案 1 :(得分:0)

  

有没有人知道我哪里出错了。

根据Documentation - Macros

  

@OSArch返回以下内容之一:&#34; X86&#34;,&#34; IA64&#34;,&#34; X64&#34; - 这是当前运行的操作系统的体系结构类型。

     

@CPUArch返回&#34; X86&#34;当CPU是32位CPU和&#34; X64&#34;当CPU为64位时。

示例:

Global Const $g_sTpl = 'OS  : %s\nCPU : %s\n'
Global Const $g_sMsg = StringFormat($g_sTpl, @OSArch, @CPUArch)

ConsoleWrite($g_sMsg)

答案 2 :(得分:-1)

试试这个

&#13;
&#13;
#include <MsgBoxConstants.au3>
if FileExists (@HomeDrive&"\Program Files (x86)") then
   $arc=64
Else
   $arc=32
EndIf
MsgBox("Hello", "Bit", "The computer that the program is been run on is a "&$arc&"bit one.")
&#13;
&#13;
&#13;

或者

&#13;
&#13;
#include <MsgBoxConstants.au3>
if FileExists (@HomeDrive&"\Program Files (x86)") then
   $arc=64
Else
   $arc=32
EndIf
$path=@HomeDrive&"\Program Files (x86)"
MsgBox("Hello", $path, "The computer that the program is been run on is a "&$arc&"bit one.")
&#13;
&#13;
&#13;

你的代码没有用,因为你现在没有反斜杠检查我编辑了你的代码