Files

43 lines
1.8 KiB
C#
Raw Permalink Normal View History

2025-08-23 21:39:21 +08:00
using Ink_Canvas.Helpers;
2025-07-21 16:00:31 +08:00
using IWshRuntimeLibrary;
2025-08-23 21:39:21 +08:00
using System;
using System.Windows;
2025-05-25 09:29:48 +08:00
namespace Ink_Canvas {
2025-08-23 21:39:21 +08:00
public partial class MainWindow : PerformanceTransparentWin {
2025-05-25 09:29:48 +08:00
public static bool StartAutomaticallyCreate(string exeName) {
try {
var shell = new WshShell();
var shortcut = (IWshShortcut)shell.CreateShortcut(
Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "\\" + exeName + ".lnk");
//设置快捷方式的目标所在的位置(源程序完整路径)
2025-08-23 21:39:21 +08:00
shortcut.TargetPath = System.Windows.Forms.Application.ExecutablePath;
2025-05-25 09:29:48 +08:00
//应用程序的工作目录
//当用户没有指定一个具体的目录时,快捷方式的目标应用程序将使用该属性所指定的目录来装载或保存文件。
shortcut.WorkingDirectory = Environment.CurrentDirectory;
//目标应用程序窗口类型(1.Normal window普通窗口,3.Maximized最大化窗口,7.Minimized最小化)
shortcut.WindowStyle = 1;
//快捷方式的描述
shortcut.Description = exeName + "_Ink";
//设置快捷键(如果有必要的话.)
//shortcut.Hotkey = "CTRL+ALT+D";
shortcut.Save();
return true;
}
catch (Exception) { }
return false;
}
public static bool StartAutomaticallyDel(string exeName) {
try {
2025-08-23 21:39:21 +08:00
System.IO.File.Delete(Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "\\" + exeName +
".lnk");
2025-05-25 09:29:48 +08:00
return true;
}
catch (Exception) { }
return false;
}
}
}