and again its me another problem

[pascal]type
TKeyBuff = array [0..256] of char;
var
KeyBuff : ^TKeyBuff;[/pascal]
and just a couple a lines down :

[pascal] DirectInput8Create(GetModuleHandle(nil),DIRECTINPU T_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(m_Hwnd,InputCo opFlags);
m_pDInputDevice.Acquire;

case m_pDInputDevice.GetDeviceState(sizeof(KeyBuff),Key Buff) of
DIERR_INVALIDPARAM : MessageBox(m_hwnd,'Invalid Parameters','',MB_OK);
DIERR_INPUTLOST : MessageBox(m_hwnd,'Input Lost','',MB_OK);
DIERR_NOTACQUIRED : MessageBox(m_hwnd,'Not Acquired','',MB_OK);
DIERR_NOTINITIALIZED : MessageBox(m_hwnd,'Not Initialized','',MB_OK);
E_PENDING : MessageBox(m_hwnd,'Pending','a',MB_OK );
end;[/pascal]

the code looks good and the compiler gives no error but when i run it
it gives me Invalid Parameters so my gues is that the getdevicestate is called with bad arguments but so far i couldnt fix it, help please

what am i doing wrong