title: Find handle of MainForm in vb.net WPF
body: <p>I am trying to find the handle of a VB.Net WPF application. I have tried various hWnd IntPtr commands with no luck</p>
  
  <p>Me.Handle gives the error 'Handle' is not a parameter of MainWindow</p>
  
  <p>Dim itnrp As IntPtr = Process.GetCurrentProcess().MainWindowHandle </p>
  
  <p>gives the error:</p>
  
  <p>error BC30657: 'ToPointer' has a return type that is not supported or parameter types that are not supported.</p>
  
  <p>If I try putting it into a function to try and get the type that the above error appears to refer to like this...:</p>
  
  <pre><code>Public Function GetHandleOfWindow()
      winHandle = Process.GetCurrentProcess().MainWindowHandle.GetType()
      'Return winHandle
  End Function
  </code></pre>
  
  <p>I get the same error BC30657 as previous</p>
  
  <p>If I try: </p>
  
  <p><code>Public winHandle As IntPtr
  winHandle = New WindowInteropHelper(Me).Handle</code></p>
  
  <p>I get the same error BC30657 as previous</p>
  
  <p>Any help would be much appreciated!!</p>