Using Firemonkey. I have an editor program which is launched by my main program. While running the editor program, I want to open a second instance of the editor program from within the editor program. For instance to edit the selected data as a new file, without closing the original form.

I want to start a second instance of the program, not just open a second copy of the form. The reason for this is some run-time initialization that needs to be independent of the current form, and the user can arbitrarily close out any instance of the editor without affecting the other instances.

What is the best method for opening a second instance of the program from within the program?

smd wrote:What is the best method for opening a second instance of the program from within the program?

AFAIK, FireMonkey does not provide services for that. You will have to use platform-specific code for it. For instance, on Windows you can pass the return value of ParamStr(0) (the path to the .exe file for the calling process) to the Win32 CreateProcess() function.

Do you know of any issues with using POSIX compliant C routines on the various platforms? Specificially I am thinking of the spawn() routines. I tried the stldlib system() command. it launches the program but also opens a third window for the command shell. The RAD documentation lists the spawn command in the process.h library. spawn() should be POSIX compliant. But I am having a hard time finding whether the various platforms support it. I ran into problems a few years ago on some "special" systems that did not allow programs to "spawn()" probably for security reasons.

After reading a bunch of information about the various platforms, I decided that the hassle factor is huge. So I am just going to restructure my program so that everything runs as a "child form" from the main application. That is the problem with legacy code. What used to work fine in a POSIX compliant environment is getting harder to implement. Instead of the various platforms providing "universal and consistent" access to system services, they are increasingly "dumming down" the interfaces while actually increasing the complexity to do "real programs". Seems so many platform developers, including Embarcadero, seem to think everyone is writing just a few types of "toy programs", but leave "real programs" that do "real work" struggling to find a way to be implemented.