Example #1
0
		public static void CreateShortcut(string title, string linkPath, string filePath, Hotkey hotkey = null)
		{
			var shellType = Type.GetTypeFromProgID("WScript.Shell");
			dynamic shell = Activator.CreateInstance(shellType);
			var shortcut = shell.CreateShortcut(linkPath);

			if (hotkey != null)
			{
				shortcut.Hotkey = hotkey.Text;
			}

			shortcut.Description = title;
			shortcut.TargetPath = filePath;
			shortcut.Save();

			Marshal.ReleaseComObject(shell);
		}
Example #2
0
        public static void CreateShortcut(string title, string linkPath, string filePath, Hotkey hotkey = null)
        {
            var     shellType = Type.GetTypeFromProgID("WScript.Shell");
            dynamic shell     = Activator.CreateInstance(shellType);
            var     shortcut  = shell.CreateShortcut(linkPath);

            if (hotkey != null)
            {
                shortcut.Hotkey = hotkey.Text;
            }

            shortcut.Description = title;
            shortcut.TargetPath  = filePath;
            shortcut.Save();

            Marshal.ReleaseComObject(shell);
        }