/// <summary> /// 获取本机所有App及路径 /// </summary> /// <returns>返回DataTable集合</returns> public static DataTable GetLocalApps() { DataTable dt = new DataTable(); dt.Columns.Add("位置", typeof(string)); dt.Columns.Add("应用名称", typeof(string)); string subPath = @"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\"; RegistryKey subKey = Registry.LocalMachine.OpenSubKey(subPath, true); string[] allAppNames = subKey.GetSubKeyNames(); foreach (string name in allAppNames) { object value = Registry.LocalMachine.OpenSubKey(subPath + name, false).GetValue(string.Empty); string appFullPath = value == null ? string.Empty : value.ToString(); if (File.Exists(appFullPath)) { dt.Rows.Add(Path.GetFileName(appFullPath), appFullPath); } } return dt; }