123456789101112131415161718192021222324252627282930313233 |
- using Microsoft.Win32;
- using System;
- using System.Security.AccessControl;
- public static class ReadWeChatPathClass
- {
- /// <summary>
- /// 读取微信路径
- /// </summary>
- /// <returns></returns>
- 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";
- }
- }
|