问题
I'm fairly new to Windows programming. I'm doing a simple launcher app for WinCE using VC++ (not MFC). So far I've created the basic interface and buttons and stuff. I just wanted to know the best way to launch an external application when the user clicks the button (on BN_CLICKED).
I found some methods such as ShellExecute, CreateProcess and others. But I couldn't get it to work (yet?). Any suitable reference or simple example on this?
回答1:
The question don't matter that it happens inside the event of a button click, but...
ShellExecute is a good way to start programs (and the default program for any other type of files) in Windows, but use CreateProcess if you need a return code, or if you need the ability to wait for the program to finish.
回答2:
Nevermind. I found a working example on MSDN - a comment by a user. For anyone interested, you can go to this CreateProcess() article and scroll down to a comment entitled "Working code for creating two processes "p1.exe" and "p2.exe" using CreateProcess() Method"
Thanks!
来源:https://stackoverflow.com/questions/1517953/how-to-launch-an-external-application-on-bn-clicked