Jump to content
  • Advertisement
Sign in to follow this  
dhulli

DirectInput Error

This topic is 3321 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
I haven't used DirectInput for a long time so I don't know if this is the problem, but if you haven't already, try linking to dxguid.lib.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!