【问题标题】:Determine Windows as 32- or 64bit确定 Windows 为 32 位或 64 位
【发布时间】:2014-07-06 16:39:23
【问题描述】:

这是我目前的代码:

#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.")

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

【问题讨论】:

    标签: x86 64-bit autoit cpu-architecture


    【解决方案1】:

    您需要阅读@OSArch 宏。

    返回以下之一:“X86”、“IA64”、“X64” - 这是当前运行的操作系统的体系结构类型。

    【讨论】:

    • 对于 CPU 架构,您应该使用 @CPUArch 宏。
    【解决方案2】:

    有谁知道我哪里出错了。

    根据Documentation - Macros

    @OSArch 返回以下之一:“X86”、“IA64”、“X64” - 这是当前运行操作系统的体系结构类型。

    @CPUArch 当 CPU 为 32 位 CPU 时返回“X86”,当 CPU 为 64 位时返回“X64”。

    例子:

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

    【讨论】:

      【解决方案3】:

      试试这个:

      #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.")
      

      或者这个:

      #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.")
      

      您的代码不起作用,因为您没有进行反斜杠检查。

      【讨论】:

        猜你喜欢
        • 2010-09-16
        • 2012-10-26
        • 2019-01-07
        • 2011-10-24
        • 2018-08-04
        • 1970-01-01
        • 2011-11-11
        • 1970-01-01
        • 2010-12-23
        相关资源
        最近更新 更多