How to launch an executable from PPL (by Eric Pankoke)

For any number of reasons, you might want to launch an external program from your PPL application. It’s actually rather simple to do. First of all, if you’re not writing a GUI application, you need to include the following file:

#include "windows.ppl"

If you want to launch a program and have it open normally, here’s a quick function to do so:

proc LaunchProgram(path$)
#ifdef _WIN32_WCE
path$ = wide(path$);
verb$ = wide("open");
#else
verb$ = "open";
#endif

struct(info$, SHELLEXECUTEINFO);

info.cbSize$ = sizeof(info$);
info.lpFile$ = &path$;
info.nShow$ = SW_SHOWNORMAL;
info.fMask$ = SEE_MASK_NOCLOSEPROCESS;
info.lpVerb$ = &verb$;
result$ = ShellExecuteEx(&info$);
end;

For more details on how this works, look up the ShellExecuteEx() function on MSDN. To launch an application, you use “open” for the lpVerb member of the SHELLEXECUTEINFO structure. Other supported verbs are dependent on the program that you are attempting to launch, and it will be up to you to figure those out. Path$ should be a fully qualified path / file name combination. Below is a quick demonstration that you can use in a non-GUI application to see how this works:

func WinMain()
#ifdef _WIN32_WCE
LaunchProgram(GetWinDir() + "addrbook.exe");
#else
LaunchProgram(GetWinDir() + "
\\notepad.exe");
#endif

return(false);
end;