From e442c1888ca4847b7eadcab9fc6a116a60a685f6 Mon Sep 17 00:00:00 2001 From: Alexander Date: Sun, 9 Dec 2018 16:10:44 +0200 Subject: [PATCH] Added create shortcut function --- Crypto Notepad/Form1.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Crypto Notepad/Form1.cs b/Crypto Notepad/Form1.cs index c6b4e9b..4c7be5b 100644 --- a/Crypto Notepad/Form1.cs +++ b/Crypto Notepad/Form1.cs @@ -254,6 +254,23 @@ private void MainWindow_FormClosing(object sender, FormClosingEventArgs e) } } + #region Send to Shortcut + public static void SendToShortcut() + { + string shortcutPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Microsoft\Windows\SendTo"; + string shortcutName = "Crypto Notepad" + ".lnk"; + string shortcutLocation = Path.Combine(shortcutPath, shortcutName); + string targetFileLocation = Assembly.GetEntryAssembly().Location; + + WshShell shell = new WshShell(); + IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(shortcutLocation); + shortcut.Description = "Crypto Notepad"; + shortcut.IconLocation = targetFileLocation; + shortcut.TargetPath = targetFileLocation; + shortcut.Save(); + } + #endregion + private void MainWindow_Load(object sender, EventArgs e) { string pos = ps.WindowLocation.ToString();