0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

cscの作法 その545

Posted at

概要

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");
	}
}



以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?