using Microsoft.Win32;
using System;
using System.Security.AccessControl;
public static class ReadWeChatPathClass
{
///
/// 读取微信路径
///
///
public static string ReadWeChatPath()
{
// 定义要读取的注册表路径
string registryPath = @"SOFTWARE\Tencent\WeChat";
string result = "";
// 打开注册表项
using (RegistryKey key = Registry.CurrentUser.OpenSubKey(registryPath,
RegistryKeyPermissionCheck.ReadWriteSubTree, System.Security.AccessControl.RegistryRights.FullControl))
{
if (key != null)
{
// 读取指定的键值
object value = key.GetValue("InstallPath");
if (value != null)
{
result = value.ToString();
}
}
}
return result + "\\WeChat.exe";
}
}