This one is working correctly:
[pascal][background=#FFFFFF][normal=#000000][number=#0000FF][string=#0000FF][comment=#248F24][reserved=#000000]
procedure TForm1.Button1Click(Sender: TObject);
type
TKeyBuff = array [0..255] of char;
var
KeyBuff : TKeyBuff;
m_pDInput: IDirectInput8;
m_pDInputDevice: IDirectInputDevice8;
InputCoopFlags: DWORD;
begin
DirectInput8Create(GetModuleHandle(nil), DIRECTINPUT_VERSION, IID_IDirectInput8, m_pDInput, nil);

m_pDInput.CreateDevice(GUID_SysKeyboard, m_pDInputDevice, nil);

m_pDInputDevice.SetDataFormat(c_dfDIKeyboard);

InputCoopFlags := DISCL_EXCLUSIVE + DISCL_FOREGROUND + DISCL_NOWINKEY;
m_pDInputDevice.SetCooperativeLevel(Handle, InputCoopFlags);
m_pDInputDevice.Acquire;

case m_pDInputDevice.GetDeviceState(sizeof(KeyBuff),@Ke yBuff) of
DIERR_INVALIDPARAM : MessageBox(Handle,'Invalid Parameters','',MB_OK);
DIERR_INPUTLOST : MessageBox(Handle,'Input Lost','',MB_OK);
DIERR_NOTACQUIRED : MessageBox(Handle,'Not Acquired','',MB_OK);
DIERR_NOTINITIALIZED : MessageBox(Handle,'Not Initialized','',MB_OK);
Integer(E_PENDING): MessageBox(Handle,'Pending','a',MB_OK );
end;
end;[/pascal]
Look at http://groups.yahoo.com/group/JEDI-D...s/DirectInput/ for available Delphi DirectInput examples.