DirectInput Nicht aufgelöstes Token "IID_DirectInput8W"



  • so ich hoffe mir kann hier jemand helfen, denn ich bin schon am verzweifeln, ich bekomme beim Compilieren folgende Fehlermeldungen:
    "error LNK2020: Nicht aufgelöstes Token (0A00008A) "IID_DirectInput8W"",
    "error LNK2021: Nicht aufgelöstes externes Symbol "IID_DirectInput8W""
    cpp-Datei

    #include <Dinput.h>
    #pragma comment(lib, "Dinput8.lib")
    //#pragma comment(lib, "dxguid.lib")
    
    #include "DirectInput8.h"
    
    DirectInput8::DirectInput8()
    {
    }
    
    HRESULT DirectInput8::init(HINSTANCE g_hinst)
    {
    	HRESULT         hr;
    	g_lpDI = NULL;
    
    	hr = DirectInput8Create(g_hinst, DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&g_lpDI, NULL);
    
    	/*if FAILED(hr)
    	{
            // DirectInput not available; take appropriate action
    	}*/
    
    	return S_OK;
    }
    

    und hier der h-Datei

    class DirectInput8
    {
    	protected:
    
    	public:
    		LPDIRECTINPUT8          g_lpDI; // DirectInput interface  
    
    		DirectInput8::DirectInput8();
    		HRESULT DirectInput8::init(HINSTANCE  g_hinst);
    };
    

    Also ich hab nu rausfinden können, dass es daran lag, dass ich die cpp-Datei in eine Windows Form Anwendung eingebunden habe. Allerdings würd ich schon gerne Wissen warum dieses Problem auftritt

    hier noch mal die definition von IID_IDirectInput8

    #ifdef UNICODE
    #define IID_IDirectInput8 IID_IDirectInput8W
    #define IDirectInput8 IDirectInput8W
    #define IDirectInput8Vtbl IDirectInput8WVtbl
    #else
    #define IID_IDirectInput8 IID_IDirectInput8A
    #define IDirectInput8 IDirectInput8A
    #define IDirectInput8Vtbl IDirectInput8AVtbl
    #endif
    

    und dann noch IID_IDirectInput8W

    DEFINE_GUID(IID_IDirectInput8W,    0xBF798031,0x483A,0x4DA2,0xAA,0x99,0x5D,0x64,0xED,0x36,0x97,0x00);
    


  • so hab die Lösung nun selber rausbekommen, es fehlte einfach ein

    #include <initguid.h>
    

    vor dem einbinden von Dinput.h


Anmelden zum Antworten