Other People’s Programs
One of the best ways to leverage your application’s power is to get other people’s programs to do part of the work. The Shell command makes this easy at the first level, but hardcore programmers must do more than simply call Shell. They have to hack around problems such as these:
-
Shell assumes that you are sending a child program off to perform some independent task and that you no longer care what it does. If your program depends on results from the child program, you’ll need to do extra work to determine when the program has finished.
-
Programs can return a value called an exit code, indicating their results to their parent. Shell ignores this value. You need to do extra work to get it.
-
Shell assumes that you are running a Windows-based program. If you are running either an MS-DOS or a 32-bit console application, you might want to take extra steps to run it politely.
-
Shell assumes that you are willing to let Windows decide where and how your Windows-based program will appear on the desktop. You’ll have more work to do if you don’t like the default behavior.
-
Shell assumes that you know which program you want to run, but it’s also possible to specify a document file and let Windows decide which program should work on the document.
The Test Execute program shown in Figure 11-4 on the following page illustrates some of the more interesting ways you can launch other people’s programs. You can use this program to experiment with different arguments to the various shell functions. When you’ve determined what works best for your situation, hard-code the appropriate settings.