Blitz Toolbox/DLLs/RunProgram DLL

RunProgram DLL by Picklesworth

http://dylanmccall.googlepages.com/DLL_RunProgram.zip

About

This DLL will launch a specified program and will keep track of whether or not it is still running by using Windows' process functions. It also enables the useage of various Windows functions which require a process handle.

This is an extremely useful addition to any program that uses external tools to carry out tasks, because it means that you will no longer have to worry about synchronizing programs by using arbitrary delays and other likely to fail techniques.

Source code is included so you can make changes and explore the DLL's inner workings.
It is easily possible to modify this DLL to return the window handle of the new program, or even to change a new program's titlebar text!

Functions:

RunProgram(Path$)
The program to execute is passed as a string in the Path argument. Relative file paths are possible. If a file path contains spaces, it must be surrounded by quotation marks ( Chr(34) ). Command line arguments can be added after these quotation marks.
If successful, the function will return the handle for your newly executed process.

ProgramEnded(hProcess%)
Specifies whether or not the program, whose handle is passed as the hProcess argument, still exists.
Returns True if the program has ended, or False if the program is still running.


Example Code
(Blitz3d):
process=RunProgram("notepad.exe",0)
Print process
Repeat
Until ProgramEnded()
RuntimeError "You closed the other program!"