How to make an Icon Extractor
Posted: Sat Dec 04, 2010 8:07 am
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:
---------------------------------------------------------------------------
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]()
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
Write the following code by double-clicking Button1 whose Text property was Choose:
Imports System.Drawing
Imports System.Drawing.Imaging
Code: Select all
And this is the final code. Double-click Button2 and add the following code:
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
Code: Select all
Well, that's all. It was real easy, wasn't it?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
---------------------------------------------------------------------------
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.
