【发布时间】:2013-09-11 14:22:26
【问题描述】:
我正在窗口启动中创建启动项。如果用户使用 msconfig 启动窗口取消选择该条目,我的应用程序会创建一个重复的条目。如果现有条目存在,我需要删除它或跳过创建重复项。我该怎么做?
我创建启动项的代码是这样的:-
string startUpFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "\\" + "MyexeName.exe";
if (System.IO.File.Exists(startUpFolderPath))
{
return;
}
WshShellClass wshShell = new WshShellClass();
IWshRuntimeLibrary.IWshShortcut shortcut;
shortcut = (IWshRuntimeLibrary.IWshShortcut)wshShell.CreateShortcut(startUpFolderPath);
shortcut.TargetPath = Application.ExecutablePath;
shortcut.WorkingDirectory = Application.StartupPath;
shortcut.Save();
【问题讨论】: