call to postmessage returns "access denied"
<p>Using Delphi 2007...
I have an application which uses a mutex to enforce one running instance only. In the dpr unit, if the mutex already exists, I get a handle to the running instance with <code>FindWindow</code>, no problem so far. A second instance is commonly started by a virtual printer driver with reference to a filename on the command line. If there is a command line file reference then I want to simply post a message to the running instance and halt the new instance.</p>

<p>I'm using this...</p>

<pre><code>PostMessage(hwnd,WM_STARTUP_MESSAGE,0,0); //hwnd as returned by FindWindow
</code></pre>

<p><code>WM_STARTUP_MESSAGE</code> is defined as <code>WM_APP + 6057</code></p>

<p>I have one user with the problem that the <code>WM_STARTUP_MESSAGE</code> is not processed in the main thread. From logging startup information in the dpr unit it was shown that the <code>PostMessage</code> returned false and <code>SysErrorMessage(GetLastError)</code> is:</p>

<pre><code>Zugriff verweigert (his windows german translation is Access Denied).
</code></pre>

<p>I have many, many users of this application and I have only had 2 reports of this problem and cannot reproduce here. On Windows 10 here and so is at least 1 of the problem users, the other one I'm not sure of.</p>

<p>I am using <code>ChangeWindowMessageFilterEx</code> in the main form's <code>OnCreate</code> to allow <code>WM_COPYDATA</code>. I had the idea of simply including <code>WM_STARTUP_MESSAGE</code> there as well but that leads to a crash as that function does not like that message index value, so I presume it is reserved for a specific range of message values.</p>

<p>Has anyone seen this before and can offer some guidance?</p>