Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

send message to a window handle

Tags:

c#

I'm running an exe through which I get a handle of a control in another exe. Now what I want to do is send messages to the particular handle from my exe.

like image 625
RV. Avatar asked Nov 20 '25 00:11

RV.


1 Answers

You need to import the function using:

[DllImport("user32.dll")]
public static extern int SendMessage(
                  int hWnd,      // handle to destination window
                  uint Msg,       // message
                  long wParam,  // first message parameter
                  long lParam   // second message parameter
                  );

and define the message that you want to send like:

public const int <WM_YOURMESSAGE> = <yourvalue>; 

and then call SendMessage like any other function.

like image 77
Vinay Avatar answered Nov 22 '25 14:11

Vinay



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!