Sending Messages from cmd to winform application

724 Views Asked by At

I have an applicaion in Winform and this application is launched from cmd. I want to launch my winform application once and like to send messages to winform application. Also, when I like to close my winform application from cmd.

I have written the Winform application in C#.

Please guide me.

Thanks in advance.

-Harsha

2

There are 2 best solutions below

1
On BEST ANSWER

I think you should use function FindWindow and SendMessage. Also you should overide WindProc in your C# application to process input messages.

1
On

I am not sure why you would want to do what you just described. But if you are looking at a generic way to control a winform application from another application, you can take a look at named pipes(.NET 3.5+). Otherwise you can do this by using a tcp socket in loopback mode.