forked from Ixiko/AHK-libs-and-classes-collection
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathResourceIDOfIcon.ahk
36 lines (31 loc) · 1.16 KB
/
ResourceIDOfIcon.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
ResourceIdOfIcon(Filename, IconIndex)
{
hmod := DllCall("GetModuleHandle", "str", Filename)
; If the DLL isn't already loaded, load it as a data file.
loaded := !hmod
&& hmod := DllCall("LoadLibraryEx", "str", Filename, "uint", 0, "uint", 0x2)
if !hmod
return
enumproc := RegisterCallback("_EnumIconResources","F")
VarSetCapacity(param,12,0), NumPut(IconIndex,param,0)
; Enumerate the icon group resources. (RT_GROUP_ICON=14)
DllCall("EnumResourceNames", "uint", hmod, "uint", 14, "uint", enumproc, "uint", ¶m)
DllCall("GlobalFree", "uint", enumproc)
; If we loaded the DLL, free it now.
if loaded
DllCall("FreeLibrary", "uint", hmod)
return NumGet(param,8) ? NumGet(param,4) : ""
}
_EnumIconResources(hModule, lpszType, lpszName, lParam)
{
index := NumGet(lParam+4)
if (index = NumGet(lParam+0))
{ ; for named resources, lpszName might not be valid once we return (?)
; if (lpszName >> 16 == 0), lpszName is an integer resource ID.
NumPut(lpszName, lParam+4)
NumPut(1, lParam+8)
return false ; break
}
NumPut(index+1, lParam+4)
return true
}