简体   繁体   中英

How to open a program using a program C++

I've been looking for a way to open a program using a C++ application. I'm trying to make a program which launches two programs together, for example I want to launch a game with AutoHotkey and when the game closes AutoHotkey does too.

I can't seem to find a simple answer online, I've read posts of people saying to use system() but others say not to use that because it's resource heavy which isn't something I want.

What other ways could I use to launch a program? I'm fairly new to C++ I've been using it for about a month now so I'm not very experienced at all. I know there is a way in C# to launch a program something like: Process.Start("notepad.exe").

As many different way to this would be awesome to know, thanks in advance guys.

As more of an AHK than C++ programmer, combined with the fact that AHK is arguably more simple to program, I would ask if you have considered a different approach? You could put more of the functionality in the AHK program instead of in the C++.

Ie Instead of having C++ start two programs, you could have it just start the Autohotkey program which then starts the game while it keeps running. Making the Autohotkey program check if the game is still running, and shut itself off if not, is quite easy too.

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