Real Software Forums
http://forums.realsoftware.com/

WINDOWS ICON EXTRACTOR
http://forums.realsoftware.com/viewtopic.php?f=21&t=41820
Page 1 of 1

Author:  sinner [ Tue Dec 13, 2011 5:46 pm ]
Post subject:  WINDOWS ICON EXTRACTOR

Hello everyone i wanted to share a code that extract all your windows system32 icons on to a canvas !

I hope this helps when you want to use an external icons from the system :p!!

1. Drag a canvas and a button onto your Window
3. Make a Module with a Global Integer named IconNumber

Module Code

Sub Function GetSystemIcon() As Picture
'http://msdn.microsoft.com/en-us/library/windows/desktop/ms648069%28v=vs.85%29.aspx

Try
#if TargetWin32
Soft Declare Function ExtractIconExA Lib "Shell32" ( lpszFile As CString, ByVal nIconIndex As Integer,phiconLarge As ptr, phiconSmall As ptr, ByVal nIcons As Integer ) As Integer
Soft Declare Function ExtractIconExW Lib "Shell32" ( lpszFile As WString, ByVal nIconIndex As Integer,phiconLarge As ptr, phiconSmall As ptr, ByVal nIcons As Integer ) As Integer
Declare Function DrawIconEx Lib "user32" ( hDC As Integer, xLeft As Integer, yTop As Integer,hIcon As Integer, cxWidth As Integer, cyWidth As Integer, istepIfAniCur As Integer,hbrFlickerFreeDraw As Integer, diFlags As Integer ) As Integer
Declare Function DestroyIcon Lib "user32" ( hIcon As Integer ) As Integer

Const DI_COMPAT = &H4
Const DI_DEFAULTSIZE = &H8
Const DI_IMAGE = &H2
Const DI_MASK = &H1
Const DI_NORMAL = &H3

Dim hIcon As Integer

Dim M As New MemoryBlock(4)
If System.IsFunctionAvailable( "ExtractIconExW", "Shell32" ) Then
hIcon = ExtractIconExW(SpecialFolder.System.Child("shell32.dll ").AbsolutePath, IconNumber, m, m, 1) 'WINDOWS/System32
Call ExtractIconExW(SpecialFolder.System.Child("shell32.dll ").AbsolutePath, IconNumber, m, m, 1)
IconNumber=IconNumber+1
Else
hIcon = ExtractIconExA(SpecialFolder.System.Child("shell32.dll ").AbsolutePath, IconNumber, m, m, 1) 'WINDOWS/System32
Call ExtractIconExA(SpecialFolder.System.Child("shell32.dll ").AbsolutePath, IconNumber, m, m, 1)
IconNumber=IconNumber+1
End if

If hIcon = 2 Then
Dim P As New Picture(24,24,32) '24x24 32 bits
Call DrawIconEx(P.Graphics.Handle(1) , 0, 0, M.Long(0) ,24, 24, 0, 0 , DI_NORMAL)
Call DestroyIcon( M.Long(0) )
Return P

ElseIf hIcon = 0 Then
MsgBox Str( IconNumber ) + " images found."
IconNumber=0
End
#endif
Catch Err As NilObjectException
Exit
Catch Err As OutOfBoundsException
Exit
End Try


Button Code

Canvas1.Backdrop = GetSystemIcon
Me.Caption = "Next ("+Str(IconNumber)+")"

Author:  lenpartico [ Tue Dec 13, 2011 8:04 pm ]
Post subject:  Re: WINDOWS ICON EXTRACTOR

Thanks,
But suppose I want to extract the icon of a folderitem how do I do that?
Lennox

Author:  sinner [ Wed Dec 14, 2011 8:30 am ]
Post subject:  Re: WINDOWS ICON EXTRACTOR

lenpartico wrote:
Thanks,
But suppose I want to extract the icon of a folderitem how do I do that?
Lennox


use a folderitem same way i got the system32 icons

"untested"

Sub Function GetSystemIcon( f As FolderItem ) As Picture
'Call ExtractIconExW(SpecialFolder.System.Child("shell32.dll ").AbsolutePath, IconNumber, m, m, 1)

Call ExtractIconExW(f.AbsolutePath, IconNumber, m, m, 1)
End Sub


Call It like this

Dim f As FolderItem = SpecialFolder.System.Child("shell32.dll ")
Canvas1.Backdrop = GetSystemIcon( f )

Author:  lenpartico [ Wed Dec 14, 2011 11:10 am ]
Post subject:  Re: WINDOWS ICON EXTRACTOR

Thanks,
I will try it later.
Lennox

Author:  lenpartico [ Wed Dec 14, 2011 5:40 pm ]
Post subject:  Re: WINDOWS ICON EXTRACTOR

Tried it but was unsuccessful

I don't know if it was done correctly, but the project can be downloaded here

http://www.mediafire.com/?f2516mmw26bi607

Any suggestions?

Thanks again.

Lennox

Author:  sinner [ Thu Dec 15, 2011 12:12 am ]
Post subject:  Re: WINDOWS ICON EXTRACTOR

Try this

http://hotfile.com/dl/137542620/4450408 ... n.rbp.html

Author:  lenpartico [ Thu Dec 15, 2011 9:30 am ]
Post subject:  Re: WINDOWS ICON EXTRACTOR

Thanks sinner,

Absolutely fantastic for .exe

Would it be too much to ask for it to be modifies to accommodate, files, folders and aliases?

If not, it would be greatly appreciated.

Thanks again.

Lennox

Author:  vassili1987 [ Fri Jun 29, 2012 6:45 am ]
Post subject:  Re: WINDOWS ICON EXTRACTOR

I know im gonna get grilled for this, but how do make a Module with a Global Integer named IconNumber? :oops:

Author:  shaosean [ Sun Jul 08, 2012 12:59 am ]
Post subject:  Re: WINDOWS ICON EXTRACTOR

- click on the "Project" tab
- right-click and select Add to Project > Module
- open the module
- add a property named "IconNumber" as Integer

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/