You compile the code you have into an executable and then create a process using CreateProcess, where the lpApplicationName is set to the name of the executable you created.
In case you wish to start a new process with the code you just wrote, compile the code you need to run in the process into its own executable and call CreateProcess with the name of that executable as the lpApplicationName parameter.
Example:
You have a piece of code you compile into a program that looks like this:
Code:
#include <iostream>
int main( int argc, char *argv[] )
{
for( int i = 0; i < argc; ++i )
std::cout<<argv[i]<<'\n';
return 0;
}
You then compile this into an exe named... Say in this case "Test.exe" would make sense. This just prints the command line parameters that you fed the program.
Then you have your main program like this (for example):
Code:
#include <windows.h>
#include <iostream>
#include <string>
int main( int argc, char *argv[] )
{
std::string ExeName("Test.exe"), CmdLine;
STARTUPINFO si;
ZeroMemory( &si, sizeof(si) );
PROCESS_INFORMATION pi;
GetStartupInfo( &si );
std::getline( std::cin, CmdLine );
if( !CreateProcess( ExeName.c_str(), CmdLine.c_str(), 0, 0, 0, DETACH_PROCESS, 0, 0, &si, &pi ) )
return 1;
return 0;
}
And compile this... Then you make sure that(in this case since the path for "Test.exe" is hardcoded) both executables are in the same directory and it should work.
Note that I didn't test this, so there might be syntax, logic or other errors.