i'm trying to create a process using the following code:
void GenerateCommandLine( char *commandLine,
int maxLength,
const char *imageTitle) {
const char * COMMAND_LINE_TEMPLATE = "AnalyzeImage.exe --image_file %s";
sprintf_s( commandLine,
maxLength,
COMMAND_LINE_TEMPLATE,
imageTitle
);
}
int AnalyzeCurrentImage(char* imageTitle) {
STARTUPINFO startupInfo;
PROCESS_INFORMATION processInfo;
DWORD exitCode = MAXINT;
char commandLine[ MAX_ELEMENT_LENGTH ];
commandLine[ 0 ] = '\0';
InitVariables( &startupInfo, &processInfo );
GenerateCommandLine( commandLine, MAX_ELEMENT_LENGTH, imageTitle );
printf( "-----------command line is: %s\n", commandLine );
// Start the AnalyzeImage process.
if( !CreateProcess( NULL, // No module name (use command line)
commandLine, // Command line
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
FALSE, // Set handle inheritance to FALSE
0, // No creation flags
NULL, // Use parent's environment block
NULL, // Use parent's starting directory
&startupInfo, // Pointer to STARTUPINFO structure
&processInfo ) // Pointer to PROCESS_INFORMATION structure
)
{
printf( "CreateProcess failed (%d).\n", GetLastError() );
return;
}
printf("here!!!");
// Wait until AnalyzeImage process exits.
WaitForSingleObject( processInfo.hProcess, INFINITE );
GetExitCodeProcess( processInfo.hProcess, &exitCode );
printf( "------------ Exit Code: %d\n", exitCode );
// Close process and thread handles.
CloseHandle( processInfo.hProcess );
CloseHandle( processInfo.hThread );
}
when i run this program from the command line i get the following:
"-------command line is: AnalyzwImage.exe --imgage_file img000.jpg CreateProess failed <2>"
do you have and idea why the create process is failing?
thank you