C# 检查启动文件夹是否已包含程序

C# 检查启动文件夹是否已包含程序,c#,C#,我主要想检查当前程序是否已链接到Windows启动文件夹,即使该文件有其他名称或是从其他目录运行。这是可能的,也许通过检查程序的名称 PS:我使用此代码将我的程序链接到启动文件夹: using (ShellLink shortcut = new ShellLink()) { shortcut.Target = Application.ExecutablePath; shortcut.WorkingDirectory = Path.GetDirectoryName(Applicat

我主要想检查当前程序是否已链接到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));
}

谢谢。

您需要扫描startup的“开始”菜单文件夹,并将每个快捷方式的目标路径与程序路径进行比较

WshShell shell = new WshShell(); 
var link = (IWshShortcut)shell.CreateShortcut(linkPathName); //Link the interface to our shortcut
var target = link.TargetPath;
//compare to your program's path...

尝试编写特洛伊木马程序=D


直截了当的解决方案:枚举Startup文件夹中的所有快捷方式(lnk文件),逐个打开它们,然后查看(我假设您正在使用该技术)。

我没有编写特洛伊木马;)。查看我在CharlesB的帖子上的评论。难道应用程序不可能像我上面写的那样从任何位置运行吗?因此,它不应该检查路径,它应该检查程序的名称/ID(如果存在类似的名称/ID)