Jump to content

Get resources from shell32.dll


Recommended Posts

let's say i want an image from shell32.dll but i don't want to export it so i want to directly load it from the dll and then display it in a guy any ways to do that?

Edited by jeantje
Link to comment
Share on other sites

eh actually i want to load a bitmap from a dll file

well, for icons from shell32.dll, this would load it directly to a control in your gui:

GUICtrlSetImage($controlid, "shell32.dll", 22)

not sure how you would load it as a bitmap though.

[u]You can download my projects at:[/u] Pulsar Software
Link to comment
Share on other sites

#include <GDIPlus.au3>
#include <GuiConstantsEx.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
_GDIPlus_Startup()

Dim $hGUI = GUICreate('Test')
Dim $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
Dim $hBitmap = _WinAPI_LoadBitmap(_WinAPI_GetModuleHandle('shell32.dll'), 147)
Dim $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)
GUISetState()
_GDIPlus_GraphicsDrawImage($hGraphics, $hImage, 0, 0)

GUIRegisterMsg($WM_PAINT, 'OnPaint')

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_RESTORE
            _GDIPlus_GraphicsDrawImage($hGraphics, $hImage, 0, 0)
            
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
    
    Sleep(20)
WEnd

_WinAPI_DeleteObject($hImage)
_WinAPI_DeleteObject($hBitmap)
_GDIPlus_GraphicsDispose($hGraphics)
GUIDelete()

_GDIPlus_Shutdown()

Func OnPaint($hwnd, $iMsg, $iwParam, $ilParam)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hImage, 0, 0)
    
    Return $GUI_RUNDEFMSG
EndFunc

Link to comment
Share on other sites

For example above mine I would go with this:

#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>

GUICreate("Test", 413)
$hPic = GUICtrlCreatePic("", 0, 0, 413, 72)

Local $hInstance = _WinAPI_GetModuleHandle("shell32.dll")

Local $hBitmap= _WinAPI_LoadImage($hInstance, 147, $IMAGE_BITMAP, 0, 0, 0)

Local $STM_SETIMAGE = 370
Local $iMsg = GUICtrlSendMsg($hPic, $STM_SETIMAGE, 0, $hBitmap)

GUISetState()

While 1
    If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit
WEnd
Link to comment
Share on other sites

Yes, this is possible:

#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>

GUICreate("Test", 413)
$hPic = GUICtrlCreatePic("", 0, 0, 300, 180)

Local $hInstance = _WinAPI_LoadLibraryEx(@WindowsDir&"\explorer.exe",$LOAD_LIBRARY_AS_DATAFILE )

Local $hBitmap= _WinAPI_LoadImage($hInstance, 170, $IMAGE_BITMAP, 0, 0, 0)

Local $STM_SETIMAGE = 370
Local $iMsg = GUICtrlSendMsg($hPic, $STM_SETIMAGE, 0, $hBitmap)
If $iMsg Then 
    _WinAPI_DeleteObject($iMsg)
EndIf

GUISetState()

While 1
    If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit
WEnd

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Yes, this is possible:

#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>

GUICreate("Test", 413)
$hPic = GUICtrlCreatePic("", 0, 0, 300, 180)

Local $hInstance = _WinAPI_LoadLibraryEx(@WindowsDir&"\explorer.exe",$LOAD_LIBRARY_AS_DATAFILE )

Local $hBitmap= _WinAPI_LoadImage($hInstance, 170, $IMAGE_BITMAP, 0, 0, 0)

Local $STM_SETIMAGE = 370
Local $iMsg = GUICtrlSendMsg($hPic, $STM_SETIMAGE, 0, $hBitmap)
If $iMsg Then 
    _WinAPI_DeleteObject($iMsg)
EndIf

GUISetState()

While 1
    If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit
WEnd
thank you very much
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...