Getting the handle of window in C#
Asked Answered
P

2

12

I'm trying to do some P/Invoke stuff and need the handle of the current window.

I found Getting the handle of window in C#

But it appears that only works in WPF. Is there a winForms equivalent?

Pentylenetetrazol answered 10/9, 2009 at 0:34 Comment(1)
A link that might help with P/Invoke: pinvoke.net Courtesy of Scott Hanselman, not me.Ethelinda
J
26

Control.Handle

An IntPtr that contains the window handle (HWND) of the control.

Jory answered 10/9, 2009 at 0:38 Comment(0)
W
6

Try this in your form:

IntPtr myHandle = this.Handle;

It will return the handle of the form.

Witherspoon answered 10/9, 2009 at 7:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.