Jump to content

extract icon from exe ?


faustf
 Share

Recommended Posts

how  is  possible extract  icon from exe???

i try  some  _WinAPI_ExtractIconEx

but  i dont  understund  how   use  ,  someone  can  help  :)  please  :)

#include <MsgBoxConstants.au3>
 #include <WinAPIShellEx.au3>
 #include <WinAPI.au3>

;Local $sVar = RegRead("HKEY_CLASSES_ROOT", ".avi")
;Local $sVar = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesDir")
;MsgBox($MB_SYSTEMMODAL, "Program files are in:", $sVar)
Global $svar,$svar2
 $sVar = RegRead('HKEY_CLASSES_ROOT\.avi','')


 $svar2 = RegRead ('HKEY_CLASSES_ROOT\'&$sVar&'\shell\open\command','')

;MsgBox($MB_SYSTEMMODAL, "Program files are in:", $sVar2)

;Local $test=_WinAPI_ShellExtractIcon($sVar2, '', 32, 32)
local $iResult = _WinAPI_ExtractIconEx($sVar2, 0, 0, 16, 1)
;Local $test=_WinAPI_ShellGetFileInfo ( $sVar2, $SHGFI_ICON);, 0, 0 )


MsgBox (0,'',$iResult)


;Run($sVar2)
Link to comment
Share on other sites

Link to comment
Share on other sites

?

#include <GDIPlus.au3>
#include <WinAPIShellEx.au3>

ExtractIcon(@systemdir & "\notepad.exe", @ScriptDir & "\notepad.png")

Func ExtractIcon($file, $output)
    $hIcon = _WinAPI_ShellExtractIcon($file, 0, 32, 32)
    _GDIPlus_Startup()
    $pBitmap = _GDIPlus_BitmapCreateFromHICON($hIcon)
    _GDIPlus_ImageSaveToFileEx($pBitmap, $output, _GDIPlus_EncodersGetCLSID("PNG"))
    _GDIPlus_ImageDispose($pBitmap)
    _GDIPlus_Shutdown()
    _WinAPI_DestroyIcon($hIcon)
EndFunc
Link to comment
Share on other sites

@faustf - Your variable $svar2 may be returning unwanted data along with the path to the exe. It certainly would do that on my system, where I have something like - "C:Program FilesApplian TechnologiesApplian FLV and Media Playeramp.exe" -I skins2 --started-from-file "%1"

You only want the path inside the first lot of quotes, and everything else should be stripped. It won't work otherwise.

In mikell's good example, you would be using the stripped result for the variable $file.

Edited by TheSaint

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

Look:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ListViewConstants.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>

$hGUI = GUICreate("ListView example", 300, 200)

$hListView = _GUICtrlListView_Create($hGUI, "Items|SubItems", 10, 10, 280, 150, $LVS_REPORT, $WS_EX_CLIENTEDGE)

_GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, _
                                          $LVS_EX_SUBITEMIMAGES, $LVS_EX_INFOTIP))


 Local $sVar = RegRead('HKEY_CLASSES_ROOT\.avi','')
 Local $svar2 = RegRead ('HKEY_CLASSES_ROOT\'&$sVar&'\DefaultIcon','')
 Local $asIcon=StringSplit($svar2,",")

$hImage = _GUIImageList_Create(16, 16, 5, 3)
_GUIImageList_AddIcon($hImage,StringReplace($asIcon[1],'"',''), Int($asIcon[2]))
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
_GUICtrlListView_SetImageList($hListView, $hImage, 1)

_GUICtrlListView_AddItem($hListView, "Test item")


GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd

Saludos

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...