Board index » delphi » sending a message from one application to another

sending a message from one application to another

Hello there,

can anybody give me a working example of how to send a message from an
application to another one, using sendmessage?
I'm trying to do this, but for one reason or another I don't get it
done.

In one application I send the current window-handle to a DLL like this:

var HandleProc:THandleProc;
begin
    Timer1.enabled:=false;
    DllInstance:=LoadLibrary('SNOOPDLL');
    HookProc:=GetProcAddress(DllInstance,'HookProcedure');
    Hook:=SetWindowsHookEx(WH_KEYBOARD,HookProc,DllInstance,0);
    HandleProc:=GetProcAddress(DllInstance,'SetWindowHandle');
    HandleProc(Application.Handle);
end;

The DLL has a procedure that accepts the window-handle, like this:

var WindowHandle:HWnd;

procedure SetWindowHandle(Handle:HWnd);
var s:string;
begin
  WindowHandle:=Handle;
end;

In the DLL I send a message to the other application like this:

    PostMessage(WindowHandle,WM_SYSCOMMAND,2000,wParam);

Can this be done in a more simple way?
If you have a working example, please send it to me

Anton Bil

email:a...@mail.HZeeland.nl

Visit my download-page at:
http://www.HZeeland.nl/~abil/downoad/download.html

 

Re:sending a message from one application to another


You're passing your application handle, but what if you pass your
mainform handle instead?

On Thu, 22 Jan 1998 23:10:20 +0100, Anton Bil <a...@mail.HZeeland.nl>
wrote:

Quote
>var HandleProc:THandleProc;
>begin
>    Timer1.enabled:=false;
>    DllInstance:=LoadLibrary('SNOOPDLL');
>    HookProc:=GetProcAddress(DllInstance,'HookProcedure');
>    Hook:=SetWindowsHookEx(WH_KEYBOARD,HookProc,DllInstance,0);
>    HandleProc:=GetProcAddress(DllInstance,'SetWindowHandle');
>    HandleProc(Application.Handle);
>end;

Other Threads