656863a7d0
* feat(docstring):添加docstring Signed-off-by: doudou0720 <98651603+doudou0720@users.noreply.github.com> * fix(docstring):修复部分docstring格式错误 Signed-off-by: doudou0720 <98651603+doudou0720@users.noreply.github.com> * fix(docstring):修复部分docstring Signed-off-by: doudou0720 <98651603+doudou0720@users.noreply.github.com> * chore(Docstring):MW_* 前14 * chore(Docstring):MW_* part 2 * chore(Docstring):MW_* part 3 * chore:优化缩进 * fix: 修复数学计算中的潜在除零错误和数值稳定性问题 Signed-off-by: doudou0720 <98651603+doudou0720@users.noreply.github.com> * chore:删除Rebase时多余的OOBE函数 * chore: 更新代码注释和文档格式 修复XML文档注释中的格式问题,统一使用<c>和<see>标签 更新ConfigHelper类的预留说明,明确未来扩展用途 优化TimerDisplayDate_Elapsed方法的注释,说明UI异步更新机制 合并重复的注释摘要行,提高文档可读性 添加形状识别功能的64位进程限制说明 修正视频呈现器设备选择逻辑的文档说明 * chore(IPPTLinkManager): 更新TryEndSlideShow方法的XML注释格式 * chore: 修正代码注释中的术语和格式问题 更新多个文件中的XML注释,统一使用<see langword="..."/>标记代替<c>...</c>标记 规范术语使用(如"延迟初始化"代替"懒惰初始化") 修正注释中的格式错误和补充说明 调整代码区域的注释对齐格式 --------- Signed-off-by: doudou0720 <98651603+doudou0720@users.noreply.github.com>
76 lines
3.1 KiB
C#
76 lines
3.1 KiB
C#
using IWshRuntimeLibrary;
|
|
using System;
|
|
using System.Windows;
|
|
using Application = System.Windows.Forms.Application;
|
|
using File = System.IO.File;
|
|
|
|
namespace Ink_Canvas
|
|
{
|
|
public partial class MainWindow : Window
|
|
{
|
|
/// <summary>
|
|
/// 创建开机自启动快捷方式。
|
|
/// </summary>
|
|
/// <param name="exeName">可执行文件名,用于命名快捷方式。</param>
|
|
/// <returns>创建成功返回true,失败返回false。</returns>
|
|
/// <remarks>
|
|
/// 操作包括:
|
|
/// 1. 创建Windows Shell对象
|
|
/// 2. 在启动文件夹中创建快捷方式
|
|
/// 3. 设置快捷方式的目标路径为当前可执行文件路径
|
|
/// 4. 设置工作目录为当前目录
|
|
/// 5. 设置窗口样式为普通窗口
|
|
/// 6. 设置快捷方式描述
|
|
/// 7. 保存快捷方式
|
|
/// 8. 捕获可能的异常,确保方法不会因异常而崩溃
|
|
/// </remarks>
|
|
public static bool StartAutomaticallyCreate(string exeName)
|
|
{
|
|
try
|
|
{
|
|
var shell = new WshShell();
|
|
var shortcut = (IWshShortcut)shell.CreateShortcut(
|
|
Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "\\" + exeName + ".lnk");
|
|
//设置快捷方式的目标所在的位置(源程序完整路径)
|
|
shortcut.TargetPath = Application.ExecutablePath;
|
|
//应用程序的工作目录
|
|
//当用户没有指定一个具体的目录时,快捷方式的目标应用程序将使用该属性所指定的目录来装载或保存文件。
|
|
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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除开机自启动快捷方式。
|
|
/// </summary>
|
|
/// <param name="exeName">可执行文件名,用于定位要删除的快捷方式。</param>
|
|
/// <returns>删除成功返回true,失败返回false。</returns>
|
|
/// <remarks>
|
|
/// 操作包括:
|
|
/// 1. 在启动文件夹中删除指定名称的快捷方式
|
|
/// 2. 捕获可能的异常,确保方法不会因异常而崩溃
|
|
/// </remarks>
|
|
public static bool StartAutomaticallyDel(string exeName)
|
|
{
|
|
try
|
|
{
|
|
File.Delete(Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "\\" + exeName +
|
|
".lnk");
|
|
return true;
|
|
}
|
|
catch (Exception) { }
|
|
|
|
return false;
|
|
}
|
|
}
|
|
} |