我正在尝试枚举 DirectInput 中的操纵杆。
unsigned int GetCount()
{
unsigned int counter;
LPDIRECTINPUT8 di;
HRESULT hr;
counter = 0;
di = NULL;
if (SUCCEEDED(hr = DirectInput8Create(GetModuleHandle(NULL),
DIRECTINPUT_VERSION,
IID_IDirectInput8,
(VOID**)&di, NULL)))
{
di->EnumDevices(DI8DEVCLASS_GAMECTRL, countCallback, &counter, DIEDFL_ATTACHEDONLY);
}
return counter;
}
仅供引用 - 这是使用 C 编译器的 c 文件。
我遇到了这些奇怪的错误。
error C2039: 'EnumDevices' : is not a member of 'IDirectInput8A'
error C2440: 'function' : cannot convert from 'const GUID' to 'const IID *const '
第一个指的是以 di->EnumDevices...
开头的行
第二个引用的是DirectInput8Create
中的IID_IDirectInput8
。
我已经尝试过 UNICODE 设置,看看它是否重要。不。
这感觉像是非常基本的东西。
最佳答案
IDirectInput8A 是一个类,那么您在哪里声明它?你可以复制粘贴声明吗?如果它是一个类,您应该添加 EnumDevices 作为其成员。
关于c - “枚举设备”: is not a member of 'IDirectInput8A' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26695318/