Creating Processes and Threads

The CreateProcess function creates both a process object and the main thread object of an application. CreateProcess allows the parent process to set the operating environment of the new process, including its working directory, how it should appear by default on the screen, its environment variables, its priority, and the command line it is passed. The new process will execute from the startup address and run until completion. Listing 25.1 shows a fragment of code that invokes Microsoft NotePad as a new process to edit the file named README.TXT.

Code Listing 25.1. Using CreateProcess to Run a Program
 HANDLE ViewReadMeFile() { STARTUPINFO siStartInfo; PROCESS_INFORMATION piProcessInfo; // initialize with current ...

Get Microsoft Windows 2000 API SuperBible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.