The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: ChillyWilly on September 16, 2009, 05:20:48 PM

Title: getting ordinal icon from shell32.dll to use on form
Post by: ChillyWilly on September 16, 2009, 05:20:48 PM
trying to load and use the icons inside shell32.dll to use on my form instead of loading them from a resource

invoke GetModuleHandle,CTEXT("c:\windows\system32\Shell32.DLL")
invoke GetProcAddress,eax,160                                                    ;160 should be the "run" icon
invoke Shell_GetImageLists,offset hSysImlLarge,offset hSysImlSmall


   


now how do i call SHGetFileInfo to pull the small icon from the dll ?
Title: Re: getting ordinal icon from shell32.dll to use on form
Post by: dedndave on September 16, 2009, 05:54:19 PM
there was a thread about this just a couple weeks ago
try searching "shell32.dll icon"
Title: Re: getting ordinal icon from shell32.dll to use on form
Post by: BlackVortex on September 16, 2009, 06:13:49 PM
http://www.masm32.com/board/index.php?topic=12161.0
Title: Re: getting ordinal icon from shell32.dll to use on form
Post by: ChillyWilly on September 16, 2009, 07:46:57 PM
invoke SHGetFileInfo,CTEXT("c:\windows\system32\Shell32.DLL"),0,addr sfi,\
sizeof SHFILEINFO,SHGFI_SYSICONINDEX or SHGFI_ICON or SHGFI_SMALLICON
INVOKE SendDlgItemMessage,hWin,1015,STM_SETIMAGE,IMAGE_ICON,sfi.SHFILEINFO.hIcon   


something like that gets me the dll's icon , im looking to get the smallest icon from the icon in the shell32.dll

i did it for the exes, but i need folder icons and the run icon for my app
(http://img190.imageshack.us/img190/7509/34019512.png)


Title: Re: getting ordinal icon from shell32.dll to use on form
Post by: dedndave on September 16, 2009, 08:01:11 PM
these may help...

http://msdn.microsoft.com/en-us/library/bb760433%28VS.85%29.aspx

nice little app btw - i like it
Title: Re: getting ordinal icon from shell32.dll to use on form
Post by: ChillyWilly on September 16, 2009, 08:39:20 PM
thanx  :U i do tech work and some of it involves removing spyware so i made this to help a little


i think that link is for only loading a bmp image in the toolbar
Title: Re: getting ordinal icon from shell32.dll to use on form
Post by: donkey on September 17, 2009, 03:39:09 AM
If you're just looking for a single icon, why bother with loading the image lists ? Just use LoadImage (http://msdn.microsoft.com/en-us/library/ms648045%28VS.85%29.aspx)...

invoke GetModuleHandle,CTEXT("c:\windows\system32\Shell32.DLL")
invoke LoadImage, eax, 160, IMAGE_ICON, NULL, NULL, LR_SHARED
mov [hIcon],eax


Note that you should always use the LR_SHARED flag when using images from system files.

For an example of using the system image lists you can look at my WinExplorer example on my website.
Title: Re: getting ordinal icon from shell32.dll to use on form
Post by: ChillyWilly on September 17, 2009, 04:48:37 AM
awesome i just found your site earlier and downloaded it

invoke GetModuleHandle,CTEXT("c:\windows\system32\Shell32.DLL")
invoke LoadImage, eax, 160, IMAGE_ICON, 16, 16, LR_SHARED
INVOKE SendDlgItemMessage,hWin,1015,STM_SETIMAGE,IMAGE_ICON,eax

works like a charm  :dance:
Title: Re: getting ordinal icon from shell32.dll to use on form
Post by: ChillyWilly on September 17, 2009, 05:51:51 AM
quick question if i had an icon as a resource in my program and wantedto loadit the same way would i use
   invoke   LoadIcon,hInstance,300
       invoke SendDlgItemMessage,hWin,1022,STM_SETIMAGE,IMAGE_ICON, eax

is there any way to allow me to choose to size it 16x16 small
Title: Re: getting ordinal icon from shell32.dll to use on form
Post by: ChillyWilly on September 17, 2009, 06:17:11 AM
ah i figured it out  :U
invoke LoadImage, hInstance, 300, IMAGE_ICON, 16, 16, LR_SHARED
mov [win],eax
       INVOKE SendDlgItemMessage,hWin,1023,STM_SETIMAGE,IMAGE_ICON, [win]