如何通过窗口标题找到进程,并在打开时关闭它

How to find process by windows title and close it whenever open

本文关键字:窗口标题 何通过 进程      更新时间:2023-10-16

我想在进程打开时通过窗口标题关闭进程。我是怎么做的?

在Windows上,使用FindWindow()定位具有所需标题的窗口,如果找到,则使用PostMessage()向其发布WM_QUIT消息。如果窗口在一段时间后仍在运行,那么您可能能够通过使用GetWindowThreadProcessId(), OpenProcess()TerminateProcess()来暴力杀死它,具体取决于权限。