在我的程序中使用CreateProcess函数创建了一个进程,但有时候会报如下错误:
ERROR_NO_SYSTEM_RESOURCES
1450
Insufficient system resources exist to complete the requested service.请问这个问题是因为我程序本身有问题还是,创建进程的外部exe程序有问题造成的?一般是什么原因?谢谢!

解决方案 »

  1.   

    系统资源不足,无法完成请求的服务。 
    看看CreateProcess的代码
      

  2.   

    直接运行你CreateProcess的进程会不会有问题?如果直接运行没有问题,就是你CreateProcess时参数有问题或者后续处理有问题
      

  3.   

    STARTUPINFOA StartupInfo;
    PROCESS_INFORMATION ProcessInformation;
    GetStartupInfo(&StartupInfo);
    ::CreateProcess(0,(char*)cmd.c_str(),0,0,0,0,0,0,&StartupInfo,&ProcessInformation);cmd此时为:d:\myapp.exe nodeup 172.16.1.1
    命令串格式正确,上面是日志中打印出来的!
    我主要不解的地方是:是我程序的资源紧张还是系统资源紧张造成,有可能是因为我的程序有资源泄露造成吗?
      

  4.   

    STARTUPINFO si;
    PROCESS_INFORMATION pi; ZeroMemory( &si, sizeof(si) );
    si.cb = sizeof(si);
    si.dwFlags |= STARTF_USESHOWWINDOW;
    si.wShowWindow = SW_SHOW;
    ZeroMemory( &pi, sizeof( pi ) ); char file[ 300 ] = "Explorer.exe ";
    strcat( file, dir );
    if( !CreateProcess( NULL, // No module name (use command line). 
    file, // 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. 
    &si,              // Pointer to STARTUPINFO structure.
    &pi )             // Pointer to PROCESS_INFORMATION structure.

    {
    AfxMessageBox( "CreateProcess failed." );
    }
      

  5.   

    STARTUPINFOA StartupInfo; ===> STARTUPINFO StartupInfo = { sizeof (STARTUPINFO) };
      

  6.   

    这样改试试:
    STARTUPINFOA StartupInfo;
    PROCESS_INFORMATION ProcessInformation;
    memset(&StartupInfo, 0, sizeof(StartupInfo));
    StartupInfo.cb = sizeof(StartupInfo);
    char cmdLine[MAX_PATH];
    strcpy(cmdLine, (char*)cmd.c_str());
    ::CreateProcess(0,cmdLine,0,0,0,0,0,0,&StartupInfo,&ProcessInformation);