-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathAHKType.ahk
47 lines (37 loc) · 1.5 KB
/
AHKType.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
;
; File encoding: UTF-8
;
; Based on code from SciTEDebug.ahk
AHKType(exeName)
{
FileGetVersion, vert, %exeName%
if !vert
return "FAIL"
StringSplit, vert, vert, .
vert := vert4 | (vert3 << 8) | (vert2 << 16) | (vert1 << 24)
exeMachine := GetExeMachine(exeName)
if !exeMachine
return "FAIL"
if (exeMachine != 0x014C) && (exeMachine != 0x8664)
return "FAIL"
if !(VersionInfoSize := DllCall("version\GetFileVersionInfoSize", "str", exeName, "uint*", null, "uint"))
return "FAIL"
VarSetCapacity(VersionInfo, VersionInfoSize)
if !DllCall("version\GetFileVersionInfo", "str", exeName, "uint", 0, "uint", VersionInfoSize, "ptr", &VersionInfo)
return "FAIL"
if !DllCall("version\VerQueryValue", "ptr", &VersionInfo, "str", "\VarFileInfo\Translation", "ptr*", lpTranslate, "uint*", cbTranslate)
return "FAIL"
oldFmt := A_FormatInteger
SetFormat, IntegerFast, H
wLanguage := NumGet(lpTranslate+0, "UShort")
wCodePage := NumGet(lpTranslate+2, "UShort")
id := SubStr("0000" SubStr(wLanguage, 3), -3, 4) SubStr("0000" SubStr(wCodePage, 3), -3, 4)
SetFormat, IntegerFast, %oldFmt%
if !DllCall("version\VerQueryValue", "ptr", &VersionInfo, "str", "\StringFileInfo\" id "\ProductName", "ptr*", pField, "uint*", cbField)
return "FAIL"
; Check it is actually an AutoHotkey executable
if !InStr(name:=StrGet(pField, cbField), "AutoHotkey") && !InStr(name,"Ahk2Exe")
return "FAIL"
; We're dealing with a legacy version if it's prior to v1.1
return vert >= 0x01010000 ? "Modern" : "Legacy"
}