我基本上想检查当前程序是否已经链接到Windows启动文件夹,即使该文件有另一个名称或从另一个目录运行。这是可能的,也许通过检查程序的名字?检查启动文件夹是否已经包含程序
PS:我用这个代码,以我的程序链接到启动文件夹:
using (ShellLink shortcut = new ShellLink()) {
shortcut.Target = Application.ExecutablePath;
shortcut.WorkingDirectory = Path.GetDirectoryName(Application.ExecutablePath);
shortcut.Description = "My Shorcut Name Here";
shortcut.DisplayMode = ShellLink.LinkDisplayMode.edmNormal;
shortcut.Save(Environment.GetFolderPath(Environment.SpecialFolder.Startup));
}
感谢。
难道应用程序可能从任何位置运行,就像我上面写的那样?所以它不应该检查路径,它应该检查程序的名称/ ID(如果类似的东西存在)。 – Marius
然后你必须在运行时获得程序的路径,这个http://msdn.microsoft.com/en-us/library/system.windows.forms.application.startuppath.aspx – CharlesB
感谢您的网址! – Marius