How to make an Icon Extractor

Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
13 posts Page 1 of 2
Contributors
User avatar
Usman55
VIP - Site Partner
VIP - Site Partner
Posts: 2821
Joined: Thu Dec 24, 2009 7:52 pm

How to make an Icon Extractor
Usman55
Hello everyone,

Today I have decided to write a tutorial on my Icon Extractor software which I haven't posted yet. What this software will do is that it extracts the icon from the file you choose. It then saves the icon in the format of an image. I wanted it to save as .ico and I have even done a lot of search but none of the researches worked. Mandai also tried to help me out but still it doesn't came to work. So this tutorial will show you just how to save it as an image so please don't complain. And also don't post any disappointing comments.

---------------------------------------------------------------------------

First of all, open Visual Basic 2008, create a new project, choose Windows Forms Application, type in the textbox Icon Extractor and press the OK button. As soon as you have done this, the Form1 will appear on the screen on which we will design our application and code it.


First we will do the designing and then the coding. So now we will change the Form1's properties to make it look good. Change the Form1's Text property to Icon Extractor. Change it's StartPosition property to CenterScreen. Change it's FormBorderStyle to FixedSingle. Change it's MaximizeBox and MinimizeBox property to False. Change it's Size property to 159, 104.


Now add the following things to the form:

(1)_ 1 PictureBox. Change it's Size property to 48,48. Change it's SizeMode property to Zoom. Change it's BorderStyle to Fixed3D.

(2)_ 2 Buttons. Change Button1's Text property to Choose or Browse and the Button2's Text property to Save.


Now is the time to code Form1 and it's components. So right-click on the form in the Solution Explorer and click View Code.

Type the following code before Public Class Form1:
Code: Select all
Imports System.Drawing
Imports System.Drawing.Imaging
Write the following code by double-clicking Button1 whose Text property was Choose:
Code: Select all
Dim openDLG As New OpenFileDialog
        openDLG.Title = "Select the file whose icon you want to extract."
        openDLG.Filter = "All Icon Sources (*.*)|*.*"
        If openDLG.ShowDialog = Windows.Forms.DialogResult.OK Then
            PictureBox1.Image = Drawing.Icon.ExtractAssociatedIcon(openDLG.FileName).ToBitmap
        End If
And this is the final code. Double-click Button2 and add the following code:
Code: Select all
Dim saveDLG As New SaveFileDialog
        saveDLG.Title = "Select the filename where you want to save the extracted icon."
        saveDLG.Filter = "Image File Types (*.bmp,*.gif,*.ico,*.jpg,*.jpeg,*.png,*.tiff)|*.bmp;*.gif;*.ico;*.jpg;*.jpeg;*.png;*.tiff"
        If saveDLG.ShowDialog = Windows.Forms.DialogResult.OK Then
            PictureBox1.Image.Save(saveDLG.FileName)
        End If
Well, that's all. It was real easy, wasn't it?

---------------------------------------------------------------------------

Voila! You have just completed making an Icon Extractor which extracts and then saves the icon as an image. Now debug and run it by pressing the Start Debugging button located at the main toolstrip. Test it, if it works fine then its SAVING time. You can save your project by going to File -> Save All and then pressing Save.

And there! You have your project and application that works. If you have any problem or can't understand something, please feel free to ask by either a comment or by PM. I have also attached a screenshot.

Please use the Give Thanks button and the Reputation System to appreciate my hard work. I have wrote this tutorial while making an Icon Extractor project myself so you can download the source file in the attachments.

Thank you.

Image
You do not have the required permissions to view the files attached to this post.
Image
User avatar
Axel
Coding God
Coding God
Posts: 1928
Joined: Sun Jun 27, 2010 9:15 pm

Re: How to make an Icon Extractor
Axel
well , you can't choose your size :?
http://vagex.com/?ref=25000
User avatar
Usman55
VIP - Site Partner
VIP - Site Partner
Posts: 2821
Joined: Thu Dec 24, 2009 7:52 pm

Re: How to make an Icon Extractor
Usman55
YourSocksRoxx wrote:
well , you can't choose your size :?
When did I said that you can?
Image
User avatar
Axel
Coding God
Coding God
Posts: 1928
Joined: Sun Jun 27, 2010 9:15 pm

Re: How to make an Icon Extractor
Axel
Usman55 wrote:
YourSocksRoxx wrote:
well , you can't choose your size :?
When did I said that you can?
i didn't say you said that , but it would e useful if you could
http://vagex.com/?ref=25000
User avatar
Usman55
VIP - Site Partner
VIP - Site Partner
Posts: 2821
Joined: Thu Dec 24, 2009 7:52 pm

Re: How to make an Icon Extractor
Usman55
YourSocksRoxx wrote:
Usman55 wrote:
YourSocksRoxx wrote:
well , you can't choose your size :?
When did I said that you can?
i didn't say you said that , but it would e useful if you could
I am going to add it in my next upload. I had that feature in my application since last week but I don't know the code of how to save the image with the size of the picturebox. I was using the Zoom SizeMode but it didn't worked. Any help?
Image
User avatar
shekoasinger
New Member
New Member
Posts: 23
Joined: Sat Dec 04, 2010 9:40 pm

This is great, works well. But it would be even better if you add the options of getting the icon from open processes. Like if Google Chrome is open. U just habe to time "chrome' into a box and the icon is there!

Do this by using Process.Mainmodule.Filename.Tostring to find the location of a running process. Good luck!.
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: How to make an Icon Extractor
mandai
I made a program to do that a while back: viewtopic.php?f=38&t=3625&p=25235#p25235
GoodGuy17
Coding God
Coding God
Posts: 1610
Joined: Mon Sep 07, 2009 12:25 am

Re: How to make an Icon Extractor
GoodGuy17
This has already been posted, in the exact same layout, but if you never viewed that tutorial then good job!
User avatar
Usman55
VIP - Site Partner
VIP - Site Partner
Posts: 2821
Joined: Thu Dec 24, 2009 7:52 pm

Re: How to make an Icon Extractor
Usman55
Can I get some reputation points please?
Image
User avatar
Cheatmasterbw
Coding God
Coding God
Posts: 1506
Joined: Fri Jan 01, 2010 2:30 pm

when you say extract an icon, do you mean from exe, dll, or .ico?
http://www.megaapps.tk/
13 posts Page 1 of 2
Return to “Tutorials”