title: Make a running process the active Window
body: <p>I have three Microsoft Access databases. I want to be able to switch between these programmatically. I have a void method which accepts a string parameter called dbName (my database name).</p>
  <pre><code>public void SwitchDatabase(string dbName)
  {
  
  }
  </code></pre>
  <p>I know what the MainWindowTitle of my Access Database is and each database has a different MainWindowTitle so I can create an array of the Process class and make this equal so System.Diagnostics.Process.GetProcesses(). I can then loop through my running processes until I find the one where the ProcessName is MSACCESS and the MainWindowTitle is correct like so:</p>
  <pre><code>Process[] processList = Process.GetProcesses();
  
  foreach (Process theProcess in processList)
  {
      string processName = theProcess.ProcessName;
      string mainWindowTitle = theProcess.MainWindowTitle;
  }
  </code></pre>
  <p>Once I find this, I can then grab the Process ID, and now I want to make this process my active window. How do I do this?</p>