在缓存c ++ MFC中找不到CreateProcess应用程序

时间:2015-03-04 01:58:24

标签: c++ createprocess

我正在编写一个简单的程序,它会调用CreateProcess数千次,因此需要一段时间才能运行。在我的输出窗口中,我每次都看到此消息

application "whatever.exe" not found in cache

我像这样调用CreateProcess

BOOL result = CreateProcess(NULL, g_minicapcmd,
        NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS | CREATE_NO_WINDOW, NULL, NULL, &startupInfo, &processInformation);
    if (!result)   {
            LPVOID lpMsgBuf;
            DWORD dw = GetLastError();
            FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 
                        NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, NULL);

            CString strError = (LPTSTR) lpMsgBuf;
            TRACE(_T("::executeCommandLine() failed at CreateProcess()\nCommand=%s\nMessage=%s\n\n"), g_minicapcmd, strError);
            LocalFree(lpMsgBuf);
            return false;
    } else {
            // Successfully created the process.  Wait for it to finish.
            WaitForSingleObject( processInformation.hProcess, INFINITE );

            // Close the handles.
            CloseHandle( processInformation.hProcess );
            CloseHandle( processInformation.hThread );

    }

有没有办法让它缓存或某种方式让它更快?我已经尝试将.exe加载到ramdisk上了,这有点帮助

0 个答案:

没有答案