title: Main window Handle by process name
body: <p>Delphi Xe, Win7x64</p>
  
  <p>How do I get the Main Window Handle, or at least a class, or a window name (if that process has only one window) from  the process name (a full path to exe-file).</p>
  
  <p>Example:</p>
  
  <pre><code> function MyGetWinHandle(path:String):HWND;
   ...
   handle := MyGetWinHandle('c:\windows\system32\notepad.exe');
  </code></pre>