[英]How do i a get a process window name and maintitlename by using the window handle or id?
In a button click event IEnumerable res; 在按钮中单击事件IEnumerable res;
System.Threading.Thread.Sleep(10000);
var windows = FindWindowsWithText("GrADS 2.0.2.oga.2");
GetWindowThreadProcessId(windows,out res)
Then FindWindowsWithText 然后找到WindowsWithText
public static IEnumerable<IntPtr> FindWindowsWithText(string titleText)
{
return FindWindows(delegate(IntPtr wnd, IntPtr param)
{
return GetWindowText(wnd).Contains(titleText);
});
}
Then in the variable windows i'm getting one count in this case and the handle number: [0] = 3343352 然后在这种情况下,在变量窗口中我得到一个计数和句柄号:[0] = 3343352
With this number 3343352 i need to find in the end the process in this case external process name and process mainwindowtitle. 我需要使用这个号码3343352在此情况下最终找到该进程的外部进程名称和进程mainwindowtitle。
Using this 使用这个
IEnumerable<IntPtr> res;
Not sure if it's any good i thought to get the id and then somehow using the id to get the name and mainwindowtitle. 我不确定是否想获取ID,然后以某种方式使用ID来获取名称和mainwindowtitle。 I made a mess. 我一团糟。
Simply use process = Process.GetProcessById(id)
to get the process by the ID. 只需使用process = Process.GetProcessById(id)
即可通过ID获得流程。 Then you can use process.MainWindowTitle
and process.ProcessName
. 然后,您可以使用process.MainWindowTitle
和process.ProcessName
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.