title: Win32: How to get the process/thread that owns a mutex?
body: <p>I'm working an application of which only one instance must exist at any given time. There are several possibilities to accomplish this:</p>
  
  <ul>
  <li>Check running processes for one matching our EXE's name (unreliable)</li>
  <li>Find the main window (unreliable, and I don't always have a main window)</li>
  <li>Create a mutex with a unique name (GUID)</li>
  </ul>
  
  <p>The mutex option seems to me the most reliable and elegant.</p>
  
  <p>However, before my second instance terminates, I want to post a message to the already running instance. For this, I need a handle to the thread (or the process) that owns the mutex.</p>
  
  <p>However, there seems to be no API function to get the creator/owner of a given mutex. Am I just overlooking it? Is there another way to get to this thread/process? Is there another way to go about this?</p>
  
  <p><em>Update</em>: <a href="http://sanity-free.org/143/csharp_dotnet_single_instance_application.html" rel="noreferrer">This guy</a> simply broadcast a message to <em>all</em> running processes. I guess that's possible, but I don't really like it...</p>