不知道具体的路径情况下
方法一:如果知道桌面的快捷方式
System.Diagnostics.Process.Start(@"C:\Users\lyylz\Desktop\360云盘.lnk");
Version currentVersion = Environment.OSVersion.Version;
Version compareToVersion = new Version("6.2");
if (currentVersion.CompareTo(compareToVersion) >= 0)
{//win8及其以上版本的系统
using (RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Compatibility Assistant\Store"))
{
if (key != null)
{
string[] sname = key.GetValueNames();
for (int i = 0; i < sname.Length; i++)
{
if (sname[i].ToString().Substring(0, 2) == "C:" || sname[i].ToString().Substring(0, 2) == "D:" || sname[i].ToString().Substring(0, 2) == "E:" || sname[i].ToString().Substring(0, 2) == "F:" || sname[i].ToString().Substring(0, 2) == "G:" || sname[i].ToString().Substring(0, 2) == "H:")
//查到的注册表可能有SIGN.MEDIA=2CE47846 VS2010\setup.exe,E:\win10\Opera\launcher.exe,需要判断
{int ss = sname[i].ToString().LastIndexOf("\\");
string s = sname[i].ToString().Substring(ss, sname[i].Length - ss);
string sss = s.Substring(1, s.Length - 1);
if (sss == "baiduyunguanjia.exe")
{
MessageBox.Show(sname[i].ToString());
continue;
}
}
}
}
}
}
else{
// win7及其以下版本的系统
using (RegistryKey key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Uninstall", false))
{
if (key != null)
{
//foreach (string keyName in key.GetSubKeyNames())
//{
string[] ssss = key.GetSubKeyNames();
for (int i = 0; i < ssss.Length; i++)
{
using (RegistryKey key2 = key.OpenSubKey("百度云管家", false))
{
if (key2 != null)
{
string softwareName = key2.GetValue("DisplayName", "").ToString();
string installLocation = key2.GetValue("InstallLocation", "").ToString();
if (!string.IsNullOrEmpty(installLocation))
{
//this.textBox1.AppendText(string.Format("软件名:{0} -- 安装路径:{1}\r\n", softwareName, installLocation));
string lu = installLocation.ToString();
string pp = lu.Remove(0, 1);
string ppp = lu.Remove(lu.Length - 1, 1);
Regex regex = new Regex("\"[^\"]*\"");
string result = regex.Match(installLocation).Value.Replace("\"", "");
this.textBox1.Text = result + @"\baiduyunguanjia.exe";
}
}
}
}
}
}
}