c# - 从窗口获取线程ID

标签 c# winforms winforms-interop

我需要从使用此代码在运行时创建的窗口中获取线程 ID

System.Windows.Window MyWindow = new System.Windows.Window();
MyWindow.Show();

我正在使用窗口处理程序

IntPtr WindowHandle = (new WindowInteropHelper(MyWindow)).Handle;

如何从窗口或其相应的处理程序中获取线程 ID?

最佳答案

看看GetWindowThreadProcessId方法

根据MSDN

Retrieves the identifier of the thread that created the specified window and, optionally, the identifier of the process that created the window.

关于c# - 从窗口获取线程ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10106966/

相关文章:

c# - 如何防止将 Windows 窗体发送到后面或如何将其保持在特定的 z 顺序上

wpf - 如何将 WPF 窗口添加到 WinForms 应用程序

c# - inlineShape = inlineShapes.AddPicture() ;引用任何 word 文件,而不是我创建的 Interop.Word.Application

c# - 我可以在 C# 中找到 BigInteger 的位数吗?

c# - 是否可以在 C# 中从我的 YouTube 数据 API v3 检索当前配额使用情况?

c# - 如何向现有 Winforms 控件添加属性

C# Labels TextAlign 在 OnPaint 覆盖后不起作用

c# - 无法加载 DLL “OraOps10.dll”

c# - 相同字符组成的最大子串

c# - HttpClient 的 ReadWriteTimeout 替代方案是什么