private void FillAllProgramInfo() { string path = Environment.GetFolderPath(Environment.SpecialFolder.CommonPrograms); string[] allPrograms = Directory.GetFiles(path, "*.lnk", SearchOption.AllDirectories); foreach (var link in allPrograms) { WshShell shell = new WshShell(); IWshShortcut sc = (IWshShortcut)shell.CreateShortcut(link); string targetPath = sc.TargetPath; if (Path.GetExtension(targetPath).ToLower() == ".exe") { string filename = Path.GetFileNameWithoutExtension(link).ToLower(); if (!CommonShortcuts.Contains(filename)) { CommonShortcuts.Add(filename); } if (!CommonShortcutsPath.ContainsKey(filename)) { CommonShortcutsPath.Add(filename, link); } } } }
private void FillSysEnvPATHShortcutsInfo() { var envPaths = Environment.GetEnvironmentVariable("path").Split(';'); foreach (var p in envPaths) { try { foreach (var fullpath in Directory.GetFiles(p, "*.exe")) { if (!CommonShortcuts.Contains(fullpath)) { string filename = Path.GetFileNameWithoutExtension(fullpath).ToLower(); if (!CommonShortcutsPath.ContainsValue(fullpath)) { CommonShortcuts.Add(filename); CommonShortcutsPath.Add(filename, fullpath); } } } } catch { } } }