Code:
hResult=DirectInput8Create(hInst,DIRECTINPUT_VERSION,IID_IDirectInput8,(void**)&directInputObject,0);
	CHECK_HRESULT

	hResult=directInputObject->CreateDevice(GUID_SysKeyboard,&directInputDevice,0);
	CHECK_HRESULT

	hResult=directInputDevice->SetDataFormat(&c_dfDIKeyboard);
	CHECK_HRESULT
	
	hResult=directInputDevice->SetCooperativeLevel(WinHand,DISCL_BACKGROUND|DISCL_NONEXCLUSIVE);
	CHECK_HRESULT
	
	hResult=directInputDevice->Acquire();
	CHECK_HRESULT
I am running this on my laptop with DirectX 10, and the input device in question is the laptop keyboard. I am also using the reference device rather than the hardware device, out of necessity. This program is currently running in windowed mode as well (full screen does not seem to work for me at the moment).

When I go to set the cooperative level flags, I had initially set them to DISCL_FOREGROUND | DISCL_NONEXCLUSIVE. For some reason, when I use the FOREGROUND flag, when I make the call to directInputDevice->Acquire(), it returns the hResult E_ACCESSDENIED. BACKGROUND and NONEXCLUSIVE combination was the only way I could get this to work. Is there a particular reason why this is the case?