凑个热闹
Func IsPEFile64($FilePath)
Local $hFile = FileOpen($FilePath, 16)
Local $Bin = FileRead($hFile, 1024)
FileClose($hFile)
Local $aBin[BinaryLen($Bin)]
For $i = 0 To UBound($aBin) - 1
$aBin[$i] = Number(BinaryMid($Bin, $i + 1, 1))
Next
Local $Index = $aBin[60] + $aBin[61] * 256 + $aBin[62] * 65536 + $aBin[63] * 16777216
If $aBin[0] <> 77 Or $aBin[1] <> 90 Or $aBin[$Index] <> 80 Or $aBin[$Index + 1] <> 69 Then Return 0
If $aBin[$Index + 4] = 100 And $aBin[$Index + 5] = 134 Then Return 64
Return 32
EndFunc ;==>IsPEFile64
Local $FilePath = "D:\autoit3\AutoIt3_x64.exe" ; 替换为你的文件路径
Switch IsPEFile64($FilePath)
Case 64
ConsoleWrite("64位程序" & @CRLF)
Case 32
ConsoleWrite("32位程序" & @CRLF)
Case Else
ConsoleWrite("非可执行文件" & @CRLF)
EndSwitch
|