windows 我在哪里可以找到 CreateProcess 错误代码的详细信息?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4990503/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Where can i find CreateProcess error codes' details?
提问by Tjorriemorrie
I'm running in php the following:
我在 php 中运行以下内容:
$res = proc_open($cmd, $descriptorspec, $pipes, "C:\xampp\htdocs\",null,array('bypass_shell'=>true));
Problem is that it gives the following error:
问题是它给出了以下错误:
Warning: proc_open(): CreateProcess failed, error code - 3
Where can I find out what the error means?
我在哪里可以找到错误的含义?
PS: it's on a Windows Server 2007. SP2. User is admin, full acess. PHP is version 5.3.1
PS:它在 Windows Server 2007.SP2 上。用户是管理员,完全访问。PHP 是 5.3.1 版本
回答by Matt Gibson
In Windows, CreateProcess doesn't actually return an error code. Instead you use GetLastErrorto find more details if CreateProcess fails, then use FormatMessageto turn the error code from GetLastError into a proper description. (The error codes from GetLastError can also be decoded using this list)
在 Windows 中,CreateProcess 实际上并不返回错误代码。相反,如果 CreateProcess 失败,您可以使用GetLastError查找更多详细信息,然后使用FormatMessage将错误代码从 GetLastError 转换为正确的描述。(来自 GetLastError 的错误代码也可以使用这个列表解码)
Looking at the source for proc_open(), PHP is actually doing the GetLastError() for you in the event of a failure, and the error code it's logging is the return from GetLastError() rather than from CreateProcess (which returns a BOOL, unlikely to be 3 :) )
查看 proc_open() 的源代码,PHP 实际上是在发生故障时为您执行 GetLastError(),并且它记录的错误代码是从 GetLastError() 返回而不是从 CreateProcess(它返回一个 BOOL,不太可能是 3 :) )
Note that proc_open uses this to dump the message:
请注意, proc_open 使用它来转储消息:
php_error_docref(NULL TSRMLS_CC, E_WARNING, "CreateProcess failed, error code - %u", dw);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "CreateProcess failed, error code - %u", dw);
...so that "-" you've got before the 3 is just a hyphen, not a minus sign. You're therefore getting error code 3, which, according to that listmeans "The system cannot find the path specified.".
...所以您在 3 之前的“-”只是一个连字符,而不是减号。因此,您会收到错误代码 3,根据该列表,这意味着“系统找不到指定的路径。”。