1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| Imports System.Drawing.IconLib
Imports System.Drawing.IconLib.ColorProcessing
Imports System.IO
Public Class Form1
Dim copier As String
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim OpenFileDialog1 As New OpenFileDialog()
OpenFileDialog1.Filter = "All Files (*.*)|*.*"
If DialogResult.OK = OpenFileDialog1.ShowDialog Then
TextBox1.Text = OpenFileDialog1.FileName
PictureBox1.Image = Icon.ExtractAssociatedIcon(OpenFileDialog1.FileName).ToBitmap
End If
End Sub
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
Dim SaveFileDialog1 As New SaveFileDialog()
SaveFileDialog1.Filter = "Ico file|*.ico"
If DialogResult.OK = SaveFileDialog1.ShowDialog Then
TextBox2.Text = SaveFileDialog1.FileName
copier = SaveFileDialog1.FileName
End If
End Sub
Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
Dim bm As New Bitmap(PictureBox1.Image)
Dim ico As Icon = Icon.FromHandle(bm.GetHicon)
Dim fs As New System.IO.FileStream(copier, IO.FileMode.CreateNew)
ico.Save(fs)
fs.Close()
MsgBox("L'icone à bien été copier !", MsgBoxStyle.OkOnly, "Réussi!")
TextBox1.Clear()
TextBox2.Clear()
PictureBox1.Image = Nothing
End Sub
Private Sub Button4_Click(sender As System.Object, e As System.EventArgs) Handles Button4.Click
End
End Sub
End Class |