C#应用添加桌面快捷方式和开机启动

        #region 快捷方式
        private static void CreateDesktopLnk()
        {
            string DesktopPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop);
            if (DesktopPath.ToLower().Equals(Application.StartupPath.ToLower()) == false)
                CreateDesktopLnkEx(DesktopPath, ShortCutFileName);

            //string StartupPath = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
            //CreateDesktopLnkEx(StartupPath, ShortCutFileName);
        }

        private static void CreateDesktopLnkEx(string LnkPath, string LnkFileName)
        {
            WshShell shell = new WshShell();
            IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(LnkPath + "\\" + LnkFileName);
            shortcut.TargetPath = Application.ExecutablePath;
            shortcut.Arguments = "";
            shortcut.Description = AppName;
            shortcut.WorkingDirectory = Application.StartupPath;
            shortcut.IconLocation = Application.ExecutablePath + ",0";
            shortcut.WindowStyle = 1;
            shortcut.Save();
        }
        #endregion

你可能感兴趣的:(private)