问题标签 [getlasterror]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
3 回答
11247 浏览

winapi - OpenProcess 错误 87 参数无效

我正在尝试编写一个程序,该程序从当前目录中的 MinGW 分发执行 make.exe 并利用其 STDOUT 数据和退出代码。我有一个句柄来处理我从中获取数据的 STDOUT,使用 CreatePipe 创建。当我在该管道上收到 ERROR_HANDLE_EOF 时,我假设该进程已退出并尝试获取其退出代码:

我的代码适用于我测试的所有其他 MinGW 实用程序(如 pwd、ls 等),我得到 STDOUT 和退出代码没有问题。但是当我在 make 上尝试时,上面的代码显示以下消息:

“OpenProcess(2032)失败,错误:87”

我用谷歌搜索错误代码 87,它显示“参数无效”。我看不出像 2032 这样的正进程 ID 有什么无效的。有什么想法吗?

0 投票
2 回答
4925 浏览

winsock - GetQueuedCompletionStatus returns ERROR_NETNAME_DELETED on remote socket closure

I am writing a small server-client-stuff using an I/O-Completion Port.

I get the server and client connected successfully via AcceptEx over my completion port. After the client has connected the client socket is associated with the completion port and an overlapped call to WSARecv on that socket is invoked.

Everything works just fine, until I close the client test program. GetQueuedCompletionStatus() returns FALSE and GetLastError returns

ERROR_NETNAME_DELETED

, which makes sense to me (after I read the description on the MSDN).

But my problem is, that I thought the call to GetQueuedCompletionStatus would return me a packet indicating the failure due to closure of the socket, because WSARecv would return the apropriate return value. Since this is not the case I don´t know which clients´ socket caused the error and cant act the way i need to (freeing structures , cleanup for this particular connection, etc)...

Any suggestion on how to solve this, Or hints?

Thanks:)

EDIT: http://codepad.org/WeYINasO <- the code responsible... the "error" occures at the first functions beginning of the while-loop (the call to GetCompletionStatus() which is only a wrapper for GetQueuedCompletionStatus() working fine in other cases) [Did post it there, because it looks shitty & messy in here]

0 投票
2 回答
4527 浏览

c++ - ReadFile() 表示失败,但错误代码为 ERROR_SUCCESS

ReadFile()在 Windows 上使用从串行端口读取数据。这段代码在某个时间点运行良好,但现在失败了,我正在尝试追查问题的根源,所以我怀疑这是串行配置或超时的问题,因为这些都没有改变。

ReadFile()返回 false,表示发生了错误。但是,当我立即检查 的值时GetLastError(),它返回 0,即ERROR_SUCCESS。读取的字节数为 0,所以我倾向于认为确实出了点问题,但错误代码完全没用。

有任何想法吗?谢谢。

编辑:以下是一些相关的代码片段:

0 投票
2 回答
2413 浏览

c++ - wglShareLists 失败并出现错误 6:ERROR_INVALID_HANDLE 句柄无效

我尝试在两个类之间共享一个 HPBUFFERARB:TGLForm 和 TGLForm2。(我尝试过 FBO,但有一个旧的 Borland Builder 6 版本,我无法使用 FBO 管理)

我的目标是在两个 openGL 窗口中显示相同的缓冲区。

所以我在第一个表单之外声明了这个对象:

我对其进行初始化,使其具有与第一个 GLForm 相同的像素格式:

这是我的第一个 DrawScene:“PaintGL()”绘图完美地绘制在此表单上:

这是我的第二个 GLForm 的 DrawScene:问题是我只看到彩色四边形,但这个 QUAD 没有纹理,或者纹理是空的:

=> 我如何检查这个纹理是否为空?

将其导出到位图并检查它?

=> DrawSceneForm2 中的 wglShareLists 使用 GetLastError 返回错误:

错误 6:ERROR_INVALID_HANDLE 句柄无效。

=> 有人看到这个 wglShareList 或我的代码有什么问题吗?

0 投票
1 回答
129 浏览

winapi - 各种 Windows API 调用的所有可能错误的详尽列表?

CreateFile例如。当我得到INVALID_HANDLE_VALUE时,可以返回的所有可能值是GetLastError什么?MSDN没有说。它提到了一些,我可以猜到其他的,但我如何(如果有的话)确定我的switch陈述永远不会达到default

0 投票
4 回答
4634 浏览

c++ - EnumProcessModulesEx 无法返回错误代码 299 (ERROR_PARTIAL_COPY)

我正在调用该函数EnumProcessModulesEx,但它失败了。我在 64 位机器上运行。下面是代码:

0 投票
1 回答
1073 浏览

c++ - 在 catch 块中调用的 GetLastError 产生不正确的值

今天探索一些遗留代码很有趣。碰到这个小数字:

GetLastError()返回0!这是为什么?这些功能实际上比这要复杂一些。它们确实在堆栈中包含了一些东西(DWORD、CString、BYTE[])。我应该寻找什么?

日志看起来像:

日志1:1

日志2:0

0 投票
2 回答
1888 浏览

c++ - GetThreadContext 返回错误 6,无效句柄?

输出:

我可以在任务管理器中看到暂停的进程,但我得到一个无效的句柄错误?

另外为什么 GetLastError() 在程序开始时给出 ERROR_FILE_NOT_FOUND ?

0 投票
1 回答
15839 浏览

winapi - CreateFile() 返回 INVALID_HANDLE_VALUE 但 GetLastError() 是 ERROR_SUCCESS

我正在使用CreateFile()打开一个串行端口。我有一个测试用例(太复杂而无法重新分发),它始终会导致CreateFile()returnINVALID_HANDLE_VALUEGetLastError()return ERROR_SUCCESS。从表面上看,只有当一个线程在另一个端口关闭它的同时打开该端口时,才会出现此错误。打开端口的线程遇到了这个问题。

我不知道这是否会有所不同,但稍后在代码中,我使用CreateIoCompletionPort将端口与 CompletionPort 相关联。

这是我的代码:

我很确定这种事情不应该发生。我做错什么了吗?如何让 API 返回正确的结果?


更多详细信息:此代码取自我开发的串行端口库:JPeripheral

这是实际的(未经处理的)源代码:

这是我得到的实际输出:

0 投票
2 回答
1009 浏览

c# - 托管 C++ 中奇怪的 GetLastError 返回

我对 GetLastError 和托管 C++ 有一个非常奇怪的问题。GetLastError 在从非托管代码转换到托管代码后返回一些非常奇怪的东西。

错误代码:122 - 传递给系统调用的数据区域太小。

此外,传入的 strMessage 正在发送到服务器。

非托管函数:

托管代码:

日志输出