ilyaz 0 Newbie Poster

I have a command-line exe that, when invoked from a console window works normally, i.e. when given an input file, produces a good output file. When I invoke the same tool using CreateProcess() from a VC++ 6.0 module, it does not generate the output file. The exe itself has no diagnostics so getting its return values does not give me any info about why it's failing. Below is the code before and after the Createprocess call. Can you see anything suspicious? THANKS MUCH!

===================

GetModuleFileName( NULL, szPath, sizeof( szPath ) );
char* lp = strrchr( szPath, '\\' );
*lp = 0;

char szCmdLine[2048];
sprintf(szCmdLine, "utility.exe \"%s\" \"%s\" \"%s\"", 
pstrSourceFile,strDestFile,strLogFile);

PROCESS_INFORMATION procInfo;
STARTUPINFO start;
memset( &start, 0, sizeof(start) );
start.cb  = sizeof(STARTUPINFO);
start.dwFlags = STARTF_FORCEOFFFEEDBACK | STARTF_USESHOWWINDOW;
start.lpTitle = "My utility ";
start.wShowWindow = SW_SHOWMINIMIZED;

if (!CreateProcess(NULL, szCmdLine, NULL, NULL, false, CREATE_NEW_CONSOLE | NORMAL_PRIORITY_CLASS, NULL, szPath, &start, &procInfo))
{
    //Failed to start helper conversion_module.exe process: error code  in GetLastError() 
}

DWORD dwRet=0;

rc = WaitForSingleObject(procInfo.hProcess,INFINITE);
// rc is WAIT_OBJECT_0

GetExitCodeProcess(procInfo.hProcess, &dwRet);
// dwRet is 1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.