C# 创建桌面快捷方式

/// <summary>
/// 创建桌面快捷方式
/// </summary>
/// <param name="deskTop">桌面的路径</param>
/// <param name="FileName">文件的名称</param>
/// <param name="exePath">EXE的路径</param>
/// <returns>成功或失败</returns>
public bool CreateDesktopShortcut(string deskTop, string FileName, string exePath)
{
    try
    {
        string deskTop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\";
        if (System.IO.File.Exists(deskTop + FileName + ".lnk"))  //
        {
            System.IO.File.Delete(deskTop + FileName + ".lnk");//删除原来的桌面快捷键方式
        }
        WshShell shell = new WshShell();

        //快捷键方式创建的位置、名称
        IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(deskTop + FileName + ".lnk");
        shortcut.TargetPath = exePath; //目标文件
        //该属性指定应用程序的工作目录,当用户没有指定一个具体的目录时,快捷方式的目标应用程序将使用该属性所指定的目录来装载或保存文件。
        shortcut.WorkingDirectory = System.Environment.CurrentDirectory;
        shortcut.WindowStyle = 1; //目标应用程序的窗口状态分为普通、最大化、最小化【1,3,7】
        shortcut.Description = FileName; //描述
        shortcut.IconLocation = exePath + "\logo.ico";  //快捷方式图标
        shortcut.Arguments = "";
        //shortcut.Hotkey = "CTRL+ALT+F11"; // 快捷键
        shortcut.Save(); //必须调用保存快捷才成创建成功
        return true;
    }
    catch (Exception)
    {
        return false;
    }
}
原文地址:https://www.cnblogs.com/flamegreat/p/12195752.html