How to manage an external Windows application in C #?

What is the best way to manage an external Windows application in C # (or .NET)?

So far I have managed to start the process using System.Diagnostics.Process, however this just allows me to start / kill the process. (from what I put together)

I noticed that System.Diagnostics.Process has a CloseMainWindow () procedure that will send a request to the process window. Can I use this Process class to send different messages? (if so, can someone point me in the direction where I can find out about these Windows messages)

I need to be able to manage and manage an external program in the following ways: 1) Launch 2) The process of killing 3) Show the application (full screen mode and task bar) 4) Hide the application (full screen and on the task bar)

Additional Information: Windows 7 Limited by .Net 3.5 Framework

+4
source share
4 answers

You may be able to use interop and use SendMessage to perform all your functions. See this: http://pinvoke.net/default.aspx/user32.SendMessage

+2
source

Try sending a message to this window. Take a look at SendMessage . Required Messages: SW_MINIMIZE , SW_RESTORE and SW_SHOWMAXIMIZED .

0
source

You will need to use some Win32 P / Invoke materials to send messages in a window in order to do what you want.

See this sample code on ShowWindow or SendMessage , which tells the outside window to show or hide itself. First you need to get the required window handle with FindWindowEx .

0
source

you can do whatever you want in different ways, as soon as you start the process yourself or find it in the list of running processes using the classes or methods of System.Diagnostics.Process , after which you can follow various parameters ...

for example, consider that after you have this descriptor: Process.MainWindowHandle you can send messages to this descriptor using SendMessage and PostMessage , and this allows you to do a lot; or you can use the PInvoke APIs such as SetWindowPos or ShowWindow or SetWindowLong and do basically everything ...

see this for example:

How to use ShowWindow API to hide and display a form

I can send you more links, but I would not like to link to the entire MSDN; -)

0
source

All Articles