Opening second instance of program from within

This is the forum for miscellaneous technical/programming questions.

Moderator: 2ffat

Opening second instance of program from within

Postby smd » Sun May 10, 2015 4:20 pm

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?
-----------------------------
Scott
smd
BCBJ Guru
BCBJ Guru
 
Posts: 130
Joined: Sat Nov 29, 2014 8:02 pm
Location: Las Vegas

Re: Opening second instance of program from within

Postby rlebeau » Mon May 11, 2015 12:35 pm

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.
Remy Lebeau (TeamB)
Lebeau Software
User avatar
rlebeau
BCBJ Author
BCBJ Author
 
Posts: 1498
Joined: Wed Jun 01, 2005 3:21 am
Location: California, USA

Re: Opening second instance of program from within

Postby smd » Mon May 11, 2015 8:33 pm

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.
-----------------------------
Scott
smd
BCBJ Guru
BCBJ Guru
 
Posts: 130
Joined: Sat Nov 29, 2014 8:02 pm
Location: Las Vegas

Re: Opening second instance of program from within

Postby smd » Mon May 11, 2015 8:53 pm

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.
-----------------------------
Scott
smd
BCBJ Guru
BCBJ Guru
 
Posts: 130
Joined: Sat Nov 29, 2014 8:02 pm
Location: Las Vegas


Return to Technical

Who is online

Users browsing this forum: Bing [Bot], Majestic-12 [Bot] and 17 guests