mirror of
https://github.com/huiyadanli/RevokeMsgPatcher.git
synced 2025-05-24 06:26:06 +08:00
捕获错误。修复找不到微信注册表路径时,程序闪退的问题
This commit is contained in:
parent
22b8138283
commit
43ce6ecb96
|
@ -34,7 +34,9 @@
|
|||
|
||||
## :book:使用方法
|
||||
|
||||
**请以管理员身份运行本程序,由于修改了微信的 `WeChatWin.dll` 文件,杀毒软件可能会弹出警告,放行即可**
|
||||
**请以管理员身份运行本程序,由于修改了微信的 `WeChatWin.dll` 文件,杀毒软件可能会弹出警告,放行即可。**
|
||||
|
||||
启动时会自动从注册表中获取微信的安装路径,如果没找到,需要手动选择微信路径。
|
||||
|
||||
环境要求:
|
||||
|
||||
|
|
|
@ -13,6 +13,8 @@ namespace RevokeMsgPatcher
|
|||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
try
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
|
@ -51,8 +53,23 @@ namespace RevokeMsgPatcher
|
|||
//退出
|
||||
Application.Exit();
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
|
||||
{
|
||||
MessageBox.Show(e.Exception.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
||||
{
|
||||
MessageBox.Show((e.ExceptionObject as Exception).Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,8 @@ namespace RevokeMsgPatcher
|
|||
public static string AutoFindInstallPath()
|
||||
{
|
||||
// 微信的注册表路径
|
||||
try
|
||||
{
|
||||
RegistryKey key = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Uninstall\WeChat");
|
||||
object installLocation = key.GetValue("InstallLocation");
|
||||
key.Close();
|
||||
|
@ -37,6 +39,11 @@ namespace RevokeMsgPatcher
|
|||
{
|
||||
return installLocation.ToString();
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Console.WriteLine(e.Message);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user