【问题标题】:CreateProcess Error Code 18创建进程错误代码 18
【发布时间】:2012-10-09 19:47:36
【问题描述】:

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

#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;
}

【问题讨论】:

  • 如果有什么安慰的话……代码对我来说没有错误。可能是权限、磁盘空间还是其他原因?

标签: createprocess


【解决方案1】:

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

似乎你的错误代码对应,

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

可能是权限。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-06-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-07
    • 1970-01-01
    相关资源
    最近更新 更多