简体   繁体   中英

How to run a program within a C program and interact with it

I wanted to create a program that could open another program and interact with it. For exemple, would it be possible to create a C program that opens mysql.exe with its right parameters and "paste" or print the password required for it to run? If its too hard to do in C, is there any other language that could do it easier?

IF youe are talking about command line programs, then you should look at pipes and how to use them from within C.

If we are talking about graphical/GUI programs: There is no standard way doing this, because it depends on the operating system and the GUI-Framework.

In Windows you can start a program, get its process Id, get the windows of the process and post messages to the window.

But for such tasks i would try to use some autmation language/frameworks. Maybe have a look at autoit . Controlling other programs UI and inputs is exactly that it is made for

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM