Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要使用此代码从运行时创建的窗口中获取线程 ID
System.Windows.Window MyWindow = new System.Windows.Window(); MyWindow.Show();
我正在使用窗口处理程序
IntPtr WindowHandle = (new WindowInteropHelper(MyWindow)).Handle;
如何从窗口或其对应的处理程序中获取线程 ID?
看一下GetWindowThreadProcessId方法
根据 MSDN
检索创建指定窗口的线程的标识符,以及(可选)创建窗口的进程的标识符。