3

Is there any way to get the Form from its Processhandle ? Some thing like this.

Form form = (Form)Form.FromHandle(_process.MainWindowHandle);

But this is not working.

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Ananth
  • 10,330
  • 24
  • 82
  • 109

2 Answers2

2

According to this post, that only works for window handles owned by your process. You can't use Form.FromHandle to get a form from some other process.

See also: How to use Control.FromHandle?

Community
  • 1
  • 1
Jim Mischel
  • 131,090
  • 20
  • 188
  • 351
1

It's possible to do this from within a process. Trying to grab a Form or Control from another process won't work.

Can you give us some more information as to what you're trying to do here with the Form? There may be a better way to accomplish it.

JaredPar
  • 733,204
  • 149
  • 1,241
  • 1,454