Delphi IDE prevents sending messages

I have two applications, they communicate with messages, everything works as expected if I run two compiled exe. But when I start (debug) the sender from delphi ide (bds2006, tried with delphi 7 with no luck), sendmessage does not send anything.

It seems that the ideal prohibits sending messages to another application. I am using WM_COPYDATA, on win7 64bit and borland 2006.

any idea?

Sender:

procedure TForm1.Button1Click(Sender: TObject); var dst: THandle; stringToSend : string; copyDataStruct : TCopyDataStruct; begin stringToSend := 'Hello'; copyDataStruct.dwData := 0; //use it to identify the message contents copyDataStruct.cbData := 1 + Length(stringToSend) ; copyDataStruct.lpData := PChar(stringToSend) ; SendData(copyDataStruct) ; end; procedure TForm1.SendData(const copyDataStruct: TCopyDataStruct) ; var receiverHandle : THandle; res : integer; begin receiverHandle := findwindow( pchar('TForm2'), pchar('Form2') ); if receiverHandle = 0 then begin ShowMessage('CopyData Receiver NOT found!') ; Exit; end; res := SendMessage(receiverHandle, WM_COPYDATA, Integer(Handle), Integer(@copyDataStruct)) ; end; end. 

Recipient Part:

 TForm2 = class(TForm) private procedure WMCopyData(var Msg: TWMCopyData ); message WM_COPYDATA; public end; var Form2: TForm2; implementation {$R *.dfm} { TReceiver } procedure TForm2.WMCopyData( var Msg: TWMCopyData ); begin ShowMessage( 'Received' ); end; 
+6
source share
1 answer

Here is a wild hunch. You launch an application that receives messages as an administrator. In Vista and later, integrity protection stops message delivery processes in higher integrity processes.

From the SendMessage documentation:

Sending messages depends on UIPI (User Interface Privilege Allocation). A process thread can only send messages in a thread message queue in processes with a lower or equal integrity level.

+11
source

Source: https://habr.com/ru/post/894199/


All Articles