概要
cscの作法、調べてみた。
練習問題やってみた。
練習問題
desktopにリンクを作れ。
サンプルコード
using System;
using System.IO;
using System.ComponentModel;
using System.Windows.Forms;
using System.Reflection;
class SampleProgram {
static void make() {
string appPath = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
var filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "link.lnk");
var type = Type.GetTypeFromCLSID(new Guid("72C24DD5-D70A-438B-8A42-98424B88AFB8"));
dynamic wsh = Activator.CreateInstance(type);
var shortcut = wsh.CreateShortcut(filePath);
shortcut.TargetPath = appPath + "\\pin2.exe";
shortcut.WorkingDirectory = Application.StartupPath;
shortcut.Save();
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(shortcut);
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(wsh);
}
[STAThread]
static void Main(string[] args) {
make();
Console.WriteLine("ok");
}
}
以上。