jercfd Posted August 22, 2009 Posted August 22, 2009 (edited) How can I check if a file is an icon? The header of an icon is below. I am only interested in offset 0 and 2. Offset# Size Purpose 0 2 reserved. should always be 0 2 2 type. 1 for icon (.ICO), 2 for cursor (.CUR) file 4 2 count; number of images in the file In hex, it would look like this 00 00 01 00 0# 00 # = number of images in file Also, if there is any other method to check if a file is an icon, I would gladly like to know. Edited August 22, 2009 by jercfd
Yashied Posted August 22, 2009 Posted August 22, 2009 _WinAPI_ExtractIconEx($sFile, -1, 0, 0, 0) returns the number of icons in the file. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
wolf9228 Posted August 22, 2009 Posted August 22, 2009 (edited) How can I check if a file is an icon? The header of an icon is below. I am only interested in offset 0 and 2. Offset# Size Purpose 0 2 reserved. should always be 0 2 2 type. 1 for icon (.ICO), 2 for cursor (.CUR) file 4 2 count; number of images in the file In hex, it would look like this 00 00 01 00 0# 00 # = number of images in file Also, if there is any other method to check if a file is an icon, I would gladly like to know. #Include <GDIPlus.au3> if IsIconFile("C:\au3.ico") Then MsgBox(0,"Chk","IconFile") Else MsgBox(0,"Chk","Another file") EndIf Func IsIconFile($sFileName) Local $Modhwnd , $hImage _GDIPlus_Startup () $hImage = _GDIPlus_ImageLoadFromFile($sFileName) _GDIPlus_ShutDown () if Not ($hImage) Then Return False _WinAPI_DeleteObject ($hImage) $Modhwnd = _WinAPI_GetModuleHandle(0) $HICON = DllCall("shell32.dll","hwnd","ExtractIcon","hwnd",$Modhwnd,"str",$sFileName,"int",0) if Not ($HICON[0]) Then Return False _WinAPI_DestroyIcon($HICON[0]) Return True EndFunc Edited August 23, 2009 by wolf9228 صرح السماء كان هنا
Yashied Posted August 23, 2009 Posted August 23, 2009 One problem: does not work with Vista icons (256x256, PNG compression). My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now