获取窗口句柄

  WinForm中获取窗体句柄用this.Handle就行了。

  但WPF中有点麻烦,需要先引用命名空间:

1 using System.Windows.Interop;

  然后调用方法:

1 IntPtr Handle = new WindowInteropHelper(this).Handle;

  其中this指的是要获取的Window的实例,方法返回后,Handle正是Window的句柄。

posted @ 2016-06-04 13:54  Bita  阅读(250)  评论(0编辑  收藏  举报