Sign in to follow this  
dhulli

DirectInput Error

Recommended Posts

I'm getting a linking error when I try and use DirectInput the error is:
Quote:
1>main.obj : error LNK2001: unresolved external symbol _IID_IDirectInput8W
1>C:\Projects\aaa\Debug\aaa.exe : fatal error LNK1120: 1 unresolved externals
I'm using Visual C++ 2008 with DirectX SDK (Aug 2009). I have set the path for the libraries and include files correctly. Here's the DirectInput code I'm using. Note that it does compile, just gives an error in linking:
Quote:
#define DIRECTINPUT_VERSION 0x0800

#include <Dinput.h>

#pragma comment (lib,"dinput8.lib")

IDirectInput8* g_pDI;

BOOL InitDIAndEnumAllDevices(HWND hWnd, HINSTANCE hInstance);
BOOL CALLBACK DIEnumDevices( LPCDIDEVICEINSTANCE	lpddi,
						  LPVOID pvRef);

BOOL InitDIAndEnumAllDevices(HWND hWnd,HINSTANCE hInstance)
{
	if (FAILED(DirectInput8Create(hInstance,DIRECTINPUT_VERSION,IID_IDirectInput8,(void**)&g_pDI,NULL)))
		return FALSE;
	g_pDI->EnumDevices(DI8DEVCLASS_ALL,DIEnumDevices,(LPVOID)hWnd,DIEDFL_ALLDEVICES);
	return TRUE;
}

BOOL CALLBACK DIEnumDevices(LPCDIDEVICEINSTANCE lpddi,LPVOID pvRef)
{
	int result;
	result = MessageBox((HWND)pvRef,lpddi->tszInstanceName,L"Device Found",MB_OKCANCEL);
	if (result == MB_OK)
		return DIENUM_CONTINUE;

		return DIENUM_STOP;
}
Any help would be appreciated. Thanks

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this