Advertisement
name22

Extract Icons from .dll

May 29th, 2013
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 1.93 KB | None | 0 0
  1. #include <WinAPI.au3>
  2. #include <GDIPlus.au3>
  3.  
  4. ; -Author: name22 (www.autoit.de)
  5.  
  6. $iStart = 3
  7. $iIcons = 5
  8.  
  9. $t_ahIcons = DllStructCreate("HWND[" & $iIcons & "]")
  10. $p_ahIcons = DllStructGetPtr($t_ahIcons)
  11.  
  12. _WinAPI_ExtractIconEx(@SystemDir & "\shell32.dll", $iStart, 0, $p_ahIcons, $iIcons)
  13.  
  14. _GDIPlus_Startup()
  15.  
  16. For $i = 1 To $iIcons
  17.     $hBitmap = _GDIPlus_BitmapCreateFromHICON(DllStructGetData($t_ahIcons, 1, $i))
  18.     _GDIPlus_ImageSaveToFile($hBitmap, @ScriptDir & StringFormat("\Icon%02d.bmp", $i))
  19.     _GDIPlus_BitmapDispose($hBitmap)
  20.     _WinAPI_DestroyIcon(DllStructGetData($t_ahIcons, 1, $i))
  21. Next
  22.  
  23. _GDIPlus_Shutdown()
  24.  
  25.  
  26. ; #FUNCTION# ====================================================================================================================
  27. ; Name...........: _GDIPlus_BitmapCreateFromHICON
  28. ; Description ...: Creates a  Bitmap object based on an icon
  29. ; Syntax.........: _GDIPlus_BitmapCreateFromHICON($hIcon)
  30. ; Parameters ....: $hIcon - Handle to an icon
  31. ; Return values .: Success      - Returns a handle to a new Bitmap object
  32. ;                  Failure      - 0 and either:
  33. ;                  |@error and @extended are set if DllCall failed
  34. ;                  |$GDIP_STATUS contains a non zero value specifying the error code
  35. ; Remarks .......: After you are done with the object, call _GDIPlus_ImageDispose to release the object resources
  36. ; Related .......: _GDIPlus_ImageDispose, _WinAPI_LoadImage, _WinAPI_LoadIcon
  37. ; Link ..........; @@MsdnLink@@ GdipCreateBitmapFromHICON
  38. ; Example .......; Yes
  39. ; ===============================================================================================================================
  40. Func _GDIPlus_BitmapCreateFromHICON($hIcon)
  41.     Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromHICON", "hwnd", $hIcon, "int*", 0)
  42.  
  43.     If @error Then Return SetError(@error, @extended, 0)
  44.     $GDIP_STATUS = $aResult[0]
  45.     Return $aResult[2]
  46. EndFunc   ;==>_GDIPlus_BitmapCreateFromHICON
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement