4

错误代码 18 后CreateProcess。为什么?

#include <iostream>
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
using namespace std;

int main()
{
    STARTUPINFO si;   
    PROCESS_INFORMATION  pi;
    ZeroMemory(&si, sizeof(si)); // macro fills a block of memory with zeros
    ZeroMemory(&pi, sizeof(pi)); 
    si.cb = sizeof(si);

    BOOL create_proc = CreateProcess(L"c:\\windows\\system32\\cmd.exe", NULL, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
    //printf("Error (%d)\n", GetLastError());
    if(!create_proc)
         printf("CreateProcess failed (%d).\n", GetLastError());

    // Wait until child process exits.
    WaitForSingleObject( pi.hProcess, INFINITE );

    // Close process and thread handles. 
    CloseHandle( pi.hProcess );
    CloseHandle( pi.hThread );

    //check
    printf("Error (%d)\n", GetLastError());

  return 0;
}
4

1 回答 1

0

从这里:https ://msdn.microsoft.com/en-us/library/ms681382(v=vs.85).aspx

您的错误代码似乎对应于,

ERROR_NO_MORE_FILES 18 (0x12) 没有更多文件。

可能是权限。

于 2015-06-03T20:59:39.607 回答