With this by changing second parameter in ExtractIcon() function
Code:
hIcon1 := ExtractIcon("C:\Program Files\Lingoes\Translator2\lingoes.exe", 7, 32)
STM_SETICON := 0x0170
Gui, Margin, 20, 20
Gui, Add, Text, w64 h64 hwndmypic1 0x3
SendMessage, STM_SETICON, hIcon1, 0,, Ahk_ID %mypic1%
Gui, Show
Return
GuiClose:
ExitApp
ExtractIcon(Filename, IconNumber, IconSize)
{
;most of the code is from Menu Icons v2.21
;written by Lexikos http://www.autohotkey.com/forum/topic21991.html
static ExtractIconEx, Ptr, PtrP
if !Ptr
Ptr := (A_PtrSize = 8) ? "ptr" : "uint"
If !PtrP
PtrP := (A_PtrSize = 8) ? "uptr*" : "uint*"
; LoadImage is not used..
; ..with exe/dll files because:
; it only works with modules loaded by the current process,
; it needs the resource ordinal (which is not the same as an icon index), and
; ..with ico files because:
; it can only load the first icon (of size %IconSize%) from an .ico file.
; If possible, use PrivateExtractIcons, which supports any size of icon.
if (IconSize != 16 && IconSize != 32)
if A_OSVersion in WIN_7,WIN_XP,WIN_VISTA,WIN_2003,WIN_2000
if DllCall("PrivateExtractIcons", "str", Filename, "int", IconNumber-1, "int", IconSize, "int", IconSize, PtrP, h_icon, "uint*", 0, "uint",1, "uint",0,"int")
return h_icon
if !ExtractIconEx
ExtractIconEx := DllCall("GetProcAddress"
, ptr, DllCall("GetModuleHandle", str, "shell32", ptr)
, A_IsUnicode ? "astr":"str" ; Always an ANSI string.
, "ExtractIconEx" . (A_IsUnicode ? "W":"A"), ptr)
; Use ExtractIconEx, which only returns 16x16 or 32x32 icons.
; if DllCall(ExtractIconEx, "str", Filename, "int", IconNumber-1, PtrP, h_icon, PtrP, h_icon_small, "uint", 1)
if DllCall(ExtractIconEx, "str", Filename, "int", IconNumber-1, PtrP, h_icon, PtrP, h_icon_small, "uint", 1)
{
SysGet, SmallIconSize, 49
; Use the best-fit size; delete the other. Defaults to small icon.
if (IconSize <= SmallIconSize) {
DllCall("DestroyIcon", ptr, h_icon)
h_icon := h_icon_small
} else
DllCall("DestroyIcon", ptr, h_icon_small)
; I think PrivateExtractIcons resizes icons automatically,
; so resize icons returned by ExtractIconEx for consistency.
if (h_icon && IconSize)
h_icon := DllCall("CopyImage", ptr, h_icon, "uint", 1, "int", IconSize, "int", IconSize, "uint", 4|8, ptr)
}
return h_icon ? h_icon : 0
}