Link to home
Start Free TrialLog in
Avatar of John500
John500Flag for United States of America

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 = ExecuteAndWaitForCompletion(ComndArray);

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
Avatar of lrcuess
lrcuess

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I am afraid you should look into documentation of your utility program isql. It, and only it, dictates the command line format.

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.
Avatar of John500

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.