ERROR_INVALID_ORDINAL 到底是什么意思?
LoadLibrary 函数返回给我错误代码 182。来自 MSDN:
ERROR_INVALID_ORDINAL:“操作系统无法运行 %1”
有人对这个错误有更好的描述吗?
The LoadLibrary function is returning to me the error code 182. From MSDN:
ERROR_INVALID_ORDINAL: "The operating system cannot run %1"
Does anyone have a better description of what this error is?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
非常晦涩的错误。然而,术语“序数”与 DLL 密切相关。 DLL 包含导出函数列表以及导入函数列表。它所依赖的其他 DLL。这些导出和导入通常有一个名称,但这不是必需的。他们总是有一个数字,这个数字就是“序数”。
要开始诊断此问题,请使用 SDK 的 Dumpbin.exe 工具。首先运行此命令:
然后查看导出列表。您应该看到序数和名称。如果一切正常,请运行
以获取依赖项列表。它很有可能在数量上依赖于另一个 DLL 中的函数,而该 DLL 没有。无论如何,类似的事情。通过使用 DependencyWalker 工具,您或许可以减少工作量。如果第一步失败,那么在构建 DLL 时就会出现严重错误。如果第二步失败,那么您可能会遇到某种 DLL Hell 问题。
Very obscure error. The term "ordinal" is however strongly associated with a DLL. A DLL contains a list of exported functions as well as a list of imported functions. Other DLLs that it has a dependency on. These exports and imports usually have a name, but that's not required. They always have a number, the number is the "ordinal".
To start diagnosing this, use the SDK's Dumpbin.exe tool. Run this first:
and look at the list of exports. You should see the ordinal as well as the name. If that all checks out, run
to get a list of the dependencies. Odds are good that it has a dependency on a function in another DLL by number that this DLL doesn't have. Something like that anyway. You can probably make it less laborious by using the DependencyWalker tool. If the first step fails then something went drastically wrong when the DLL was built. If the second step fails then you're probably looking at some kind of DLL Hell problem.
您确定此错误来自 LoadLibrary 吗? Windows DLL 允许您按名称和序号值指定导出。也就是说,每个功能都可以用一个数字来标识。如果您调用 GetProcAddress 并指定无效序数,则会收到此错误。
我最好的猜测是,您正在加载的 DLL 正在其 DllMain 中调用 GetProcAddress 并指定无效的序数。这会导致它失败,并且当您调用 GetLastError 时,您会得到 ERROR_INVALID_ORDINAL,因为这是发生的最后一个错误。
Are you sure that this error is coming from LoadLibrary? Windows DLLs allow you to specify exports by name and ordinal value. That is, each function can be identified by a number. If you call GetProcAddress and specify an invalid ordinal, then you'll get this error.
My best guess is that the DLL that you're loading is calling GetProcAddress in its DllMain and specifying an invalid ordinal. This causes it to fail, and when you call GetLastError, you get ERROR_INVALID_ORDINAL since that's the last error that occurred.