[#] 修复微信寻找路径时的 bug #282

This commit is contained in:
huiyadanli 2022-01-22 23:48:41 +08:00
parent 5a54a21391
commit 3a3e5306e7
4 changed files with 60 additions and 26 deletions

View File

@ -1,5 +1,7 @@
using RevokeMsgPatcher.Model; using RevokeMsgPatcher.Model;
using RevokeMsgPatcher.Utils; using RevokeMsgPatcher.Utils;
using System;
using System.Collections.Generic;
namespace RevokeMsgPatcher.Modifier namespace RevokeMsgPatcher.Modifier
{ {
@ -15,11 +17,14 @@ namespace RevokeMsgPatcher.Modifier
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public override string FindInstallPath() public override string FindInstallPath()
{
try
{ {
string installPath = PathUtil.FindInstallPathFromRegistry("QQLite"); string installPath = PathUtil.FindInstallPathFromRegistry("QQLite");
if (!IsAllFilesExist(installPath)) if (!IsAllFilesExist(installPath))
{ {
foreach (string defaultPath in PathUtil.GetDefaultInstallPaths(@"Tencent\QQLite")) List<string> defaultPathList = PathUtil.GetDefaultInstallPaths(@"Tencent\QQLite");
foreach (string defaultPath in defaultPathList)
{ {
if (IsAllFilesExist(defaultPath)) if (IsAllFilesExist(defaultPath))
{ {
@ -31,6 +36,11 @@ namespace RevokeMsgPatcher.Modifier
{ {
return installPath; return installPath;
} }
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
return null; return null;
} }

View File

@ -1,5 +1,7 @@
using RevokeMsgPatcher.Model; using RevokeMsgPatcher.Model;
using RevokeMsgPatcher.Utils; using RevokeMsgPatcher.Utils;
using System;
using System.Collections.Generic;
namespace RevokeMsgPatcher.Modifier namespace RevokeMsgPatcher.Modifier
{ {
@ -15,11 +17,14 @@ namespace RevokeMsgPatcher.Modifier
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public override string FindInstallPath() public override string FindInstallPath()
{
try
{ {
string installPath = PathUtil.FindInstallPathFromRegistry("{052CFB79-9D62-42E3-8A15-DE66C2C97C3E}"); string installPath = PathUtil.FindInstallPathFromRegistry("{052CFB79-9D62-42E3-8A15-DE66C2C97C3E}");
if (!IsAllFilesExist(installPath)) if (!IsAllFilesExist(installPath))
{ {
foreach (string defaultPath in PathUtil.GetDefaultInstallPaths(@"Tencent\QQ")) List<string> defaultPathList = PathUtil.GetDefaultInstallPaths(@"Tencent\QQ");
foreach (string defaultPath in defaultPathList)
{ {
if (IsAllFilesExist(defaultPath)) if (IsAllFilesExist(defaultPath))
{ {
@ -31,6 +36,11 @@ namespace RevokeMsgPatcher.Modifier
{ {
return installPath; return installPath;
} }
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
return null; return null;
} }

View File

@ -1,5 +1,7 @@
using RevokeMsgPatcher.Model; using RevokeMsgPatcher.Model;
using RevokeMsgPatcher.Utils; using RevokeMsgPatcher.Utils;
using System;
using System.Collections.Generic;
using System.IO; using System.IO;
namespace RevokeMsgPatcher.Modifier namespace RevokeMsgPatcher.Modifier
@ -17,12 +19,15 @@ namespace RevokeMsgPatcher.Modifier
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public override string FindInstallPath() public override string FindInstallPath()
{
try
{ {
string installPath = PathUtil.FindInstallPathFromRegistry("Wechat"); string installPath = PathUtil.FindInstallPathFromRegistry("Wechat");
string realPath = GetRealInstallPath(installPath); string realPath = GetRealInstallPath(installPath);
if (string.IsNullOrEmpty(realPath)) if (string.IsNullOrEmpty(realPath))
{ {
foreach (string defaultPath in PathUtil.GetDefaultInstallPaths(@"Tencent\Wechat")) List<string> defaultPathList = PathUtil.GetDefaultInstallPaths(@"Tencent\QQ");
foreach (string defaultPath in defaultPathList)
{ {
realPath = GetRealInstallPath(defaultPath); realPath = GetRealInstallPath(defaultPath);
if (!string.IsNullOrEmpty(realPath)) if (!string.IsNullOrEmpty(realPath))
@ -35,6 +40,11 @@ namespace RevokeMsgPatcher.Modifier
{ {
return realPath; return realPath;
} }
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
return null; return null;
} }
@ -45,6 +55,10 @@ namespace RevokeMsgPatcher.Modifier
/// <returns></returns> /// <returns></returns>
private string GetRealInstallPath(string basePath) private string GetRealInstallPath(string basePath)
{ {
if (basePath == null)
{
return null;
}
if (IsAllFilesExist(basePath)) if (IsAllFilesExist(basePath))
{ {
return basePath; return basePath;

View File

@ -61,7 +61,7 @@ namespace RevokeMsgPatcher
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message + "\n" + ex.StackTrace.Trim(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
#endif #endif
} }
@ -69,12 +69,12 @@ namespace RevokeMsgPatcher
static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e) static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
{ {
MessageBox.Show(e.Exception.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(e.Exception.Message + "\n" + e.Exception.StackTrace.Trim(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{ {
MessageBox.Show((e.ExceptionObject as Exception).Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show((e.ExceptionObject as Exception).Message + "\n" + (e.ExceptionObject as Exception).StackTrace.Trim(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
} }