从其他应用程序中查找运行WPF应用程序exe的错误消息 [英] find the error messages in running WPF application exe from other application

查看:64
本文介绍了从其他应用程序中查找运行WPF应用程序exe的错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个WPF应用程序,它应该找到所有正在运行的exe的错误消息。没有用于运行exe的事件记录。我尝试使用自动化元素和计时器,但它不适用于多个进程。还有其他任何方式来实现这个?

I have a WPF application which should find all the running exe's error messages.there is no event logging for running exe's.I tried using automation element and timer but it will not work for multiple processes.is there any other way to implement this ?

推荐答案

我们必须使用Pinvoke GetForegroundWindow 方法。



We have to use the Pinvoke GetForegroundWindow method.

IntPtr hwnd = GetForegroundWindow();
            uint pid;
            GetWindowThreadProcessId(hwnd, out pid);
            Process proc = Process.GetProcessById((int)pid);





一旦我们获得了仅用于该进程的processid我需要运行自动化元素来查找错误窗口。这个查找活动窗口的方法每隔5分钟通过计时器运行一次,这样如果我的活动窗口(进程)发生变化,它将为该进程工作(找到错误窗口)。



once we get the processid only for that process i need to run automation element to find error window.and this method for finding active window run every 5 minutes via timer so that if my active window(Process) changes it will work(find error window) for that process.


这篇关于从其他应用程序中查找运行WPF应用程序exe的错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆