c - “枚举设备”: is not a member of 'IDirectInput8A'

标签 c directx directinput

我正在尝试枚举 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/

相关文章:

c++ - 这个错误是什么意思: "error: expected specifier-qualifier-list before ' type_name'"?

c - C 中的隐式函数声明

创建包含 0 和 1 的二维数组

c++ - DirectX 12 SDK LNK2001

c++ - 无法打开包含文件 : 'basewin.h' : No such file or directory

c# - 在 DirectInput 应用程序中使用 SendInput API 模拟键盘

c - 数组的内存映射

windows - Directx 11.1 中 D3DXCOLOR 结构的新等效项?

C++ Directx鼠标输入在失去焦点后表现得很奇怪

c# - SlimDX DirectInput 初始化