directX directInput键盘抛出E_accessdenied [英] directX directInput Keyboard throws E_accessdenied
问题描述
我正在尝试使用DirectInput键盘,并且我的代码抛出了一个奇怪的错误。
我可以经历所有的创建,设置,它们都返回S_OK,但是当我尝试运行时
I am trying to work with DirectInput keyboard, and my code is throwing a weird error. I can go through the creation, and setting of everything and they all return S_OK, but when I try to run
HRESULT hr;
hr = m_pDIKeyboard->GetDeviceState( sizeof(keyBuffer), (LPVOID)&keyBuffer );
hr返回(十六进制地址)访问代码无效,并且在我进行检查时
hr comes back as (hex address) "access code is invalid", and when I do a check for
if(FAILED(hr))
它以E_ACCESSDENIED
的形式返回,在keyBuffer或该行的任何部分都没有错误(或关于该问题的警告)。
it comes back as E_ACCESSDENIED there are no errors (or warnings for that matter) on the keyBuffer, or any part of the line.
对此有任何想法
推荐答案
IDirectInputDevice8 :: GetDeviceState
给出以下可能的返回值:
The documentation for IDirectInputDevice8::GetDeviceState
give the following possible return values:
返回值
方法成功,返回值为DI_OK。如果该方法失败,则返回值可以是以下错误值之一:DIERR_INPUTLOST,DIERR_INVALIDPARAM,DIERR_NOTACQUIRED,DIERR_NOTINITIALIZED,E_PENDING。
Return Value
If the method succeeds, the return value is DI_OK. If the method fails, the return value can be one of the following error values: DIERR_INPUTLOST, DIERR_INVALIDPARAM, DIERR_NOTACQUIRED, DIERR_NOTINITIALIZED, E_PENDING.
您应检查 DIERR _ *
宏是否与 E_ACCESSDENIED
重叠。
You should check that none of the DIERR_*
macros overlap with E_ACCESSDENIED
.
此外,我见过一些代码处理 E_ACCESSDENIED
的方式与 DIERR_INPUTLOST
相同。您可能想要尝试重新获取
输入内容,然后再进行一次输入。
Further, some code I've seen handles E_ACCESSDENIED
the same way as DIERR_INPUTLOST
. You might want to try to re-Acquire
the input and have another go.
这篇关于directX directInput键盘抛出E_accessdenied的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!