Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Transfer Startup Data

Status
Not open for further replies.

sweep123

Technical User
May 1, 2003
185
0
0
GB
I need to start up to 4 instances of an application from another application. But can have 1 and 4 running only or 1, 2 and 4 running (i.e. not 3).

How do you pass a number to allow the application starting up to know which instance to be.
Currently if a start 1 and 3 then 1 and 2 run as 2 knows that 1 is running so takes the next number available; it needs to be told to be 3.

I use the following to start the applications: (Check box for each one)

if(g_pIDU1->GetCheck ()) // Check box 1 set?
{
GetStartupInfo(&si[0]);
CreateProcess(NULL, "c:\\IDU_Emu\\debug\\IDU_Emu.exe", // Name of app to launch
NULL, // Default process security attributes
NULL, // Default thread security attributes
FALSE, // Don't inherit handles from the parent
0, // Normal priority
NULL, // Use the same environment as the parent
NULL, // Launch in the current directory
&si[0], // Startup Information
&pi[0]); // Process information stored upon return CW_USEDEFAULT
}

etc
 
CreateProcess(NULL, "c:\\IDU_Emu\\debug\\IDU_Emu.exe 1",...
CreateProcess(NULL, "c:\\IDU_Emu\\debug\\IDU_Emu.exe 2",...
CreateProcess(NULL, "c:\\IDU_Emu\\debug\\IDU_Emu.exe 3",...

Ion Filipski
1c.bmp
 
CreateProcess(NULL, "c:\\IDU_Emu\\debug\\IDU_Emu.exe 1",...
CreateProcess(NULL, "c:\\IDU_Emu\\debug\\IDU_Emu.exe 2",...
CreateProcess(NULL, "c:\\IDU_Emu\\debug\\IDU_Emu.exe 3",...

I mean you can pass parameters in the command line.

Ion Filipski
1c.bmp
 
OK thanks, one other question how does the other task pick the parameter's up.

The other task is a Win32 MFC application!

I know for a console application you can process the command line.

Many thanks,

Sweep123
 
you should #include<stdarg.h> and use global variables __argc and __argv. The first one is the int number of parameters and the second one is a char** (array of char*) which contains the parameters.
Another way to pick parameters, is the third parameter of function WinMain, if you use WinMain.

Ion Filipski
1c.bmp
 
OK thanks, now got it working.

Placed the code in the WinApp file and created a global variable to allow the main dialog to access the data passed over.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top