Hello Guys, I am the Vector and today I will teach them to create a Simple Icon Extractor.
First let's add it to our source above the public class form1:
Code:
Imports System . IO 'without spaces
Now below the public form1:
Code:
Dim extractpath As String
Dim savepath As String
Now Add 2 Buttons and Rename it for:
Browse File
Extract Icon
Okay Guys, Now we have to put this on Browse File Button:
Code:
Dim open As New OpenFileDialog
If open.ShowDialog = Windows.Forms.DialogResult.OK Then
PictureBox1.Image = Icon.ExtractAssociatedIcon(open.FileName).ToBitmap()
extractpath = open.FileName
End If
So, Now put this on Extract Icon:
Code:
Dim save As New SaveFileDialog
save.Filter = "PNG File (*.png)|*.png|Icon Files(*.ico)|*.ico|JPEG Files(*.jpg)|*.jpg|Bitmap Files(*.bmp)|*.bmp"
If save.ShowDialog = Windows.Forms.DialogResult.OK Then
savepath = save.FileName
End If
If savepath = Nothing Then
MsgBox("Select a path to save the icon first", MsgBoxStyle.Critical, "Select path!")
Exit Sub
End If
Try
Dim bm As New Bitmap(PictureBox1.Image)
Dim ico As Icon = Icon.FromHandle(bm.GetHicon)
Dim fs As New FileStream(savepath, IO.FileMode.CreateNew)
ico.Save(fs)
fs.Close()
Catch ex As Exception
MsgBox("A following error occured: " & vbCrLf & vbCrLf & ex.ToString)
End Try
Okay, now add to your form 1 Picture Box and 1 Timer and your properties enable = true.
Now put this on timer:
Code:
If extractpath = Nothing Then
Button2.Enabled = False
Else
Button2.Enabled = True
End If
Okay Guys now we finished the Icon Extractor, remember that is a simple source modified by me! original source is from @
Intellectual
Thanks for this tutorial please!