반응형

* C# EXE File icon 가져오기 예제...

 

Main

 

 

- 사용한 컨트롤: Button 2개, Label 1개

 

전체 소스 코드

Form1.vb

 

Public Class Form1

    Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click
        'File Open
        Dim ofd As OpenFileDialog = New OpenFileDialog()

        ofd.Filter = "EXE File(*.exe) | *.exe"

        If ofd.ShowDialog() = DialogResult.OK Then

            label1.Text = ofd.FileName

        End If


    End Sub

    Private Sub button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button2.Click
        'Icon Save
        '파일이 아니라면
        If Not System.IO.File.Exists(label1.Text) Then Return

        'exe file icon get
        Dim icn As Icon = Icon.ExtractAssociatedIcon(label1.Text)
        Dim img As Image = Image.FromHbitmap(icn.ToBitmap().GetHbitmap())
        img.Save("C:\TEST.ico")
        MessageBox.Show("icon Image Save Success...")

    End Sub

End Class

 

 

*예제 결과

 

 

 




반응형

+ Recent posts