使用VC++开发考场随机排座系统
2009-02-27 20:02:47 来源:WEB开发网cmdline=exePath+"XLSConverter.exe "+"C:\tempXLS\temp.xls"+" txt C:\tempXLS";
char buf[1024],cmdll[1024];
sprintf(cmdll,"%s",cmdline);
cmdll[sizeof(cmdll)-1]=0;
sprintf(buf,"%s","XLSConverter.exe");
buf[sizeof(buf)-1] = 0;
//通过在新的进程中以命令形式调用转换引擎XLSConverter.exe
STARTUPINFO startInfo;
startInfo.cb = sizeof(STARTUPINFO);
startInfo.lpReserved = NULL;
startInfo.lpTitle = buf;
startInfo.lpDesktop = NULL;
startInfo.dwX = 0;
startInfo.dwY = 0;
startInfo.dwXSize = 0;
startInfo.dwYSize = 0;
startInfo.dwXCountChars = 0;
startInfo.dwYCountChars = 0;
startInfo.dwFlags = STARTF_USESTDHANDLES;
startInfo.wShowWindow = 0; //SW_SHOWDEFAULT;
startInfo.lpReserved2 = NULL;
startInfo.cbReserved2 = 0;
startInfo.hStdInput = 0;
startInfo.hStdOutput = 0;
startInfo.hStdError = 0;
//产生新的进程,运行命令行,调用转换引擎进行转换
int nRet=CreateProcess(
NULL,
cmdll,
NULL,
NULL,
TRUE,
0, //CREATE_NEW_CONSOLE
NULL,
NULL,
&startInfo,
&pidInfo);
if(!nRet)
{
AfxMessageBox("调用引擎失败,程序将退出!",MB_OK|MB_ICONSTOP);
return -1;
}
DWORD dwWait=WaitForSingleObject(pidInfo.hProcess, INFINITE); //等待进程结束
return;
更多精彩
赞助商链接