c# 바탕화면에 바로가기 아이콘 생성
c# 바탕화면에 바로가기 아이콘 생성
COM 참조 추가
Windows Script Host Object Model
Namespace 추가
using IWshRuntimeLibrary;
public Form1()
{
InitializeComponent();
}
WshShell wsh;
private void button1_Click(object sender, EventArgs e)
{
string path = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
wsh = new WshShell();
IWshRuntimeLibrary.IWshShortcut myShotCut;
myShotCut = (IWshRuntimeLibrary.IWshShortcut)wsh.CreateShortcut(path + "/test.lnk");
myShotCut.TargetPath = @"c:\reg\인명부자산프로그램.exe";
myShotCut.Description = "shotcut test";
myShotCut.IconLocation = @"c:\reg\assign.ico";
myShotCut.Save();
MessageBox.Show("완료");
}
//// 바로가기를 만든다.
//IWshRuntimeLibrary.IWshShortcut MyShortcut;
//// 바로가기를 저장할 경로를 지정한다.
//MyShortcut = (IWshRuntimeLibrary.IWshShortcut)WshShell.CreateShortcut(@"C:\MyShortcut.lnk");
//// 바로가기에 프로그램의 경로를 지정한다.
//MyShortcut.TargetPath = Application.ExecutablePath;
//// 바로가기의 description을 지정한다.
//MyShortcut.Description = "Launch My Application";
//// 바로가기 아이콘을 지정한다.
//MyShortcut.IconLocation = Application.StartupPath + @"\app.ico";
//// 바로가기를 저장한다.
//MyShortcut.Save();