DirectInput8Create 失败:E_INVALIDARG
我将 DirectInput 与 Direct3D 11 一起使用,并针对 x64 进行编译,并从这一行得到 E_INVALIDARG:
HRESULT hr = DirectInput8Create(hInstance, DIRECTINPUT_VERSION, IID_IDirectInput8, reinterpret_cast<void **>(&this->_d8Input), 0);
当我设置断点来查看发生的情况时,我没有看到任何无效参数的迹象。我的 hInstance 有效,_d8Input 指针也有效,DIRECTINPUT_VERSION 设置为 0x0800。
我以前用过D3D9直接输入,方式完全相同,没有任何问题。 我缺少什么?
谢谢。
I'm using DirectInput with Direct3D 11, and compiling for x64 and I get an E_INVALIDARG from this line:
HRESULT hr = DirectInput8Create(hInstance, DIRECTINPUT_VERSION, IID_IDirectInput8, reinterpret_cast<void **>(&this->_d8Input), 0);
When I set a break point to look at what is going on I get no sign of any invalid arguments. My hInstance is valid, so is the _d8Input pointer and the DIRECTINPUT_VERSION is set to 0x0800.
I've used direct input with D3D9 before, in the exact same way and didn't have any problems.
What am I missing ?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好的,刚刚下载了最新的 DirectX SDK 和 Platform SDK,因此我可以在 64 位中测试它,我创建了一个非常简单的 64 位应用程序。
对于我添加的 stdafx.h 文件:
在 _tWinMain 函数中我添加:
对于链接器选项,我添加了 dinput8.lib 和 dxguid.lib
编译,检查应用程序是否为 64 位,并且它执行干净而不会生成无效参数消息。我在 outPtr 变量中获得了有效值。我什至查看了 dinput.h 文件的内容,这似乎表明 DIRECTINPUT_VERSION 默认设置为 0x0800。
我很茫然,这个“应该在 32 位和 64 位中都有效”。
当我使用 NULL 值而不是 outPtr 时,出现无效指针错误,因此这似乎表明问题不是指针中的无效值。
当我使用有效 hInstance 以外的任何内容时,我确实得到了无效参数 - 当我用 0 替换该值时,我得到了与您看到的相同的错误。也许 hInstance 值没有正确初始化?
Ok, having just downloaded the latest DirectX SDK and Platform SDK, so I could test this in 64bit, I created an insanely simple 64bit application.
For the stdafx.h file I added:
and in the _tWinMain function I added:
for linker options, I added dinput8.lib and dxguid.lib
Compiled, checked that the application was 64bit, and it executes cleanly without generating an invalid parameter message. I get a valid value in the outPtr variable. I even looked at the content of the dinput.h file, which seems to indicate that DIRECTINPUT_VERSION is set to 0x0800 be default.
I'm at a loss, this 'just should work' in both 32bit and 64bit.
I get an invalid pointer error when I use a NULL value instead of outPtr, so that seems to indicate that the issue isn't an invalid value from the pointer.
I do get an invalid parameter when I use anything other than a valid hInstance - when I replaced the value with 0, I got the same error you saw. Perhaps the hInstance value is not initialized correctly?
好吧,事实证明我正在使用 /SUBSYSTEM:CONSOLE 进行编译,并且在使用控制台子系统时从 WinMain 传入的 hInstance 根本不适合 DirectInput8Create。
Ok, it turns out I was compiling with /SUBSYSTEM:CONSOLE and the hInstance passed in from WinMain when using a console subsystem doesn't please DirectInput8Create at all.