The postmessage call returns "access denied"

Using Delphi 2007 ... I have an application that uses a mutex to force the use of only one executable instance. In the dpr module, if the mutex already exists, I get a handle to the working instance with FindWindow, until there is a problem. The second instance is usually started using the virtual printer driver with a link to the file name on the command line. If there is a link to the command line file, I just want to send a message to the running instance and stop the new instance.

I use this ...

PostMessage(hwnd,WM_STARTUP_MESSAGE,0,0); //hwnd as returned by FindWindow

WM_STARTUP_MESSAGE defined as WM_APP + 6057

I have one user with a problem that is WM_STARTUP_MESSAGEnot being processed in the main thread. From the information about starting registration in the dpr module, it was shown that PostMessagereturns false and SysErrorMessage(GetLastError):

Zugriff verweigert (his windows german translation is Access Denied).

I have many, many users of this application, and I had only 2 posts about this problem, and I can not reproduce here. In Windows 10, there are at least 1 of the problem users here, and I'm not sure of the other.

I use ChangeWindowMessageFilterExin the main form OnCreateto allow WM_COPYDATA. I had the idea to simply include it WM_STARTUP_MESSAGE, but it crashes because this function does not like this message index value, so I assume that it is reserved for a certain range of message values.

Has anyone seen this before and can offer some recommendations?

+4
1

PostMessage() :

UIPI, , GetLastError, ​​ 5 ( ).

(UIPI) Vista

UI Privilege Level Isolation (UIPI).

initatuve Vista, . , /.

, , ChangeWindowMessageFilter(). , HWND, .

Internet Explorer - , .

Windows

(UIPI) Windows, . . SendMessage . , , . , "", WM_GETTEXT, . , WM_SETTEXT, .

...

UIPI ( ). UIPI , . :

  • .
  • SendMessage PostMessage . API , .
  • .
  • , .
  • (DLL) , .

, HWND, , , /, , . " SysInternals" , .

, , , , , , .

ChangeWidowMessageFilter/Ex() ( ). , , . HWND/MsgID, FALSE , GetLastError() , .

, - .

, Form OnCreate ChangeWindowMessageFilterEx(). , , HWND , , . , HWND, ChangeWindowMessageFilterEx(). - Form virtual CreateWnd(), :

type
  TMyForm = class(TForm)
  protected
    procedure CreateWnd; override;
  end;

procedure TMyForm.CreateWnd;
begin
  inherited;
  ChangeWindowMessageFilterEx(Handle, WM_STARTUP_MESSAGE, MSGFLT_ALLOW, nil);
end;
+10

All Articles