John500
asked on
Can the CreateProcess() function launch multiple 'functions' within a program rather than multiple exterior <br>executables?
Greetings,
I am currently using CreateProcess to launch multiple programs which are exterior to the parent program. Now however, I want to spawn multiple calls to a function within the parent program. Is this possible using 'CreateProcess()'?
Below is what I'm using now. The command line for the 'isql' program which I'm launching takes various parameters to read a file and execute its contents.
string CommandStr = "isql /U /P /S " + ServerName + " /d " + DatabaseName + " /n /i c:\\mydbscript.txt";
sprintf(ComndArray, CommandStr.c_str());
pRC = ExecuteAndWaitForCompletio n(ComndArr ay);
The ComdnArray is then passed to CreateProcess().
The program I'm now working on (completely different) launches a function which establishes a remote connection. I want to call this function multiple times. Can CreateProcess() do this? If so, how would 'CommandStr'
be modified to do this. Let's call the function connect().
Any idea if multiple streams are an issue here?
Thanks for the help!
I am currently using CreateProcess to launch multiple programs which are exterior to the parent program. Now however, I want to spawn multiple calls to a function within the parent program. Is this possible using 'CreateProcess()'?
Below is what I'm using now. The command line for the 'isql' program which I'm launching takes various parameters to read a file and execute its contents.
string CommandStr = "isql /U /P /S " + ServerName + " /d " + DatabaseName + " /n /i c:\\mydbscript.txt";
sprintf(ComndArray, CommandStr.c_str());
pRC = ExecuteAndWaitForCompletio
The ComdnArray is then passed to CreateProcess().
The program I'm now working on (completely different) launches a function which establishes a remote connection. I want to call this function multiple times. Can CreateProcess() do this? If so, how would 'CommandStr'
be modified to do this. Let's call the function connect().
Any idea if multiple streams are an issue here?
Thanks for the help!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
lrcuess,
Yes, in its very simplest form, here is the flow:
MakeConnect(string *StrArray)
{
string CommandStr;
while(!Done){
//get next value of array and make new CommandStr
CommandStr = "whatever";
CreateProcess(CommandStr);
}
}
main()
{
string Strarray[]; // holds node names
PopulateArray(Strarray); // get node names
MakeConnect(Strarray);
return;
}
alexcohn,
This program has nothing to do with SQL or any databases. It has to do with a connection to other systems on the network.
Yes, in its very simplest form, here is the flow:
MakeConnect(string *StrArray)
{
string CommandStr;
while(!Done){
//get next value of array and make new CommandStr
CommandStr = "whatever";
CreateProcess(CommandStr);
}
}
main()
{
string Strarray[]; // holds node names
PopulateArray(Strarray); // get node names
MakeConnect(Strarray);
return;
}
alexcohn,
This program has nothing to do with SQL or any databases. It has to do with a connection to other systems on the network.
Note that C++ provides much more elegant ways of connecting to external databases, via ADO or ODBC, so that you need not generate external files with SQL scripts, can keep connections alive, etc.