[IWshRuntimeLibrary] ShotCut,단축아이콘 만들기



"프로젝트 - 참조 - 서비스참조 추가" 에서 Window Script Host Object Model 를 추가 한다.

 
Created with colorer-take5 library. Type 'csharp'

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Runtime.InteropServices;
using IWshRuntimeLibrary; // COM_ => Window Script Host Object Model

namespace StikusInstallWareV1
{
    /// <summary>
    /// MainWindow.xaml에 대한 상�� 작용 논리
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        WshShell wsh;
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            string path = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
            wsh = new WshShell();
            IWshRuntimeLibrary.IWshShortcut myShotCut;
            myShotCut = (IWshRuntimeLibrary.IWshShortcut)wsh.CreateShortcut(path + "/scripter.lnk");
            myShotCut.TargetPath = "http://www.scripter.co.kr";//@"c:\";
            myShotCut.Description = "shotcut test";
            myShotCut.IconLocation = Environment.CurrentDirectory +"/"+"scICO_Small.ico";
            myShotCut.Save();
        }
    }
}



를 하면 간단하게 만들수 있다.


Yamecoder 야매코더_
C# 2011.05.20 17:04
Powerd by Tistory, designed by criuce
rss