IT Engineering/C#.net
C# 바로가기 아이콘 만들기 Shortcut
glorymind
2021. 1. 28. 18:14
반응형
C#에서 바로가기 아이콘을 생성하기
아래와 같이 COM 참조를 하여
Windows Script Host Object Model을 참조한다.
using 으로 IWshRuntimeLibrary 를 추가해주고
다음과 같이 코딩한다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
static WshShell wsh = new WshShell();
/// <summary>
/// 바로가기 생성
/// </summary>
static void CreateShortCut()
{
try
{
string path = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
wsh = new WshShell();
IWshRuntimeLibrary.IWshShortcut myShotCut;
myShotCut = (IWshRuntimeLibrary.IWshShortcut)wsh.CreateShortcut(path + "/Test.lnk");
myShotCut.TargetPath = Application.ExecutablePath;
myShotCut.Description = "Short Cut Create";
myShotCut.IconLocation = System.IO.Path.Combine(System.Windows.Forms.Application.StartupPath, "test.ico");
myShotCut.Save();
}
catch (Exception ex)
{
}
}
|
cs |
위치는 상관없으나 위와 같이 구현하여 호출하면 된다.
반응형