반응형
* C# EXE File icon 가져오기 예제...
- 사용한 컨트롤: Button 2개, Label 1개
전체 소스 코드
Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace CSharp_EXEIcon
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//File Open
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "EXE File(*.exe) | *.exe";
if (ofd.ShowDialog() == DialogResult.OK)
{
label1.Text = ofd.FileName;
}
}
private void button2_Click(object sender, EventArgs e)
{
//icon Save
//파일이 아니라면...
if (!System.IO.File.Exists(label1.Text)) return;
//exe file iCon get
Icon icn = Icon.ExtractAssociatedIcon(label1.Text);
//Image Save
Image img = Image.FromHbitmap(icn.ToBitmap().GetHbitmap());
img.Save("c:\\Test.ico");
img.Dispose();
MessageBox.Show("icon Image Save Success...");
}
}
}
*예제 결과
반응형
'C# Programming' 카테고리의 다른 글
[C#] [Control] Listview - Button, Progressbar, TextBox 컨트롤 삽입 (0) | 2020.05.15 |
---|---|
[C#] [Control] Listview - 그룹화 항목 만들기 (0) | 2020.05.13 |
[C#] App Configuration - Key & Value 값 읽기 (0) | 2020.05.07 |
[C#] Regex 를 이용한 간단한 이메일 주소 체크 (0) | 2020.05.04 |
[C#] String To 이진수 , 이진수 To String 으로 변환 (0) | 2020.04.30 |