Get Icon from file
Started by
Marshin
, May 08 2008 07:41 PM
4 replies to this topic
#1
Posted 08 May 2008 - 07:41 PM
not sure this is the right forum. but is it possible to get the image/icon from a saved file (*.dwg,*.pdf ...) , I have looked through the forum and couldn't find anything.
At last, after two thousand years of research, the illudium Q-36 explosive space modulator.Well, back to the old drawing board.
#2
Posted 08 May 2008 - 08:17 PM
try to search for
enumicons_v2.au3
enumicons_v2.au3
#3
Posted 08 May 2008 - 09:04 PM
MSDN Reference:SHGetFileInfo
AutoIt
Global Const $tagSHFILEINFO = "hwnd hIcon;int iIcon;dword Attr;wchar DisplayName[260];char TypeName[80]" Global Const $SHGFI_ICON = 256 Global Const $SHGFI_DISPLAYNAME = 512 Global Const $SHGFI_TYPENAME = 1024 Global Const $SHGFI_ATTRIBUTES = 2048 Global Const $SHGFI_ICONLOCATION = 4096 Global Const $SHGFI_EXETYPE = 8192 Global Const $SHGFI_SYSICONINDEX = 16384 Global Const $SHGFI_LINKOVERLAY = 32768 Global Const $SHGFI_SELECTED = 65536 Global Const $SHGFI_ATTR_SPECIFIED = 131072 Global Const $SHGFI_LARGEICON = 0 Global Const $SHGFI_SMALLICON = 1 Global Const $SHGFI_OPENICON = 2 Global Const $SHGFI_SHELLICONSIZE = 4 Global Const $SHGFI_PIDL = 8 Global Const $SHGFI_USEFILEATTRIBUTES = 16 Func _SHGetFileInfo(ByRef $tFileInfo,Const $File,Const $dwAttr = 0,Const $Flags = 0) If NOT $tFileInfo Then $tFileInfo = DllStructCreate($tagSHFILEINFO) EndIF If @error Then Return SetError(1,0,$tFileInfo) Local $Ret = DllCall("shell32.dll","int","SHGetFileInfo","str",$File,"dword",$dwAttr, _ "ptr",DllStructGetPtr($tFileInfo),"uint",DllStructGetSize($tFileInfo),"uint",$Flags) If $Ret[0] = 0 Then Return SetError(2,0,False) Return SetError(0,$Ret[0],$tFileInfo) EndFunc
#4
Posted 09 May 2008 - 04:19 AM
nobbe thank you, but enumicons_v2.au3 only shows the icons for dll's and exe's.
danielkza thank you for the code, it looks like it will do what I need to do but I am not completely sure how to make it work.
danielkza thank you for the code, it looks like it will do what I need to do but I am not completely sure how to make it work.
At last, after two thousand years of research, the illudium Q-36 explosive space modulator.Well, back to the old drawing board.
#5
Posted 09 May 2008 - 10:25 PM
nobbe thank you, but enumicons_v2.au3 only shows the icons for dll's and exe's.
danielkza thank you for the code, it looks like it will do what I need to do but I am not completely sure how to make it work.
Func _ShellGetAssocIcon(Const $szFile,Const $IconFlags = 0) Local $tFileInfo = DllStructCreate($tagSHFILEINFO) If @error Then Return SetError(1,@extended,0) EndIf Local $Ret = DllCall("shell32.dll","int","SHGetFileInfo","str",$szFile,"dword",0, _ "ptr",DllStructGetPtr($tFileInfo),"uint",DllStructGetSize($tFileInfo),"uint",BitOr($SHGFI_ICON,$IconFlags)) MsgBox(0,0,@error) Return DllStructGetData($tFileInfo,"hIcon") EndFunc
Don't forget to call _WinAPI_DestroyIcon after you're done with the icon.Check the extra flags in the MSDN page in the first post.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users





