Skip to main content
gamedev.net
🔒 Locked

DirecInput acting were wird, help needed!

Started by snoddas14 Mar 20, 2007 at 2:36 PM 3 replies 500+ views
Original Post
snoddas14
snoddas14
hey i got this strange thing.... i complie it and it get no error, but then when i run it MsVs .net ends it and get´s me an break error! here is the code!

bool InputD3D(HINSTANCE hInst, HWND wndHandle)
{
	hr = DirectInput8Create(hInst, DIRECTINPUT_VERSION, IID_IDirectInput8, 
		(void**)&din, NULL);
	if(FAILED(hr))
	{
		return FALSE;
	}
	hr = din->CreateDevice(GUID_SysKeyboard, &dinkey, NULL);
	if(FAILED(hr))
	{
		return FALSE;
	}

	hr =dinkey->SetDataFormat(&c_dfDIKeyboard);
	if(FAILED(hr))
	{
		return FALSE;
	}
	hr = dinkey->SetCooperativeLevel(wndHandle, DISCL_BACKGROUND);
	if(FAILED(hr))
	{
		return FALSE;
	}

	return TRUE;
}
void DInput(void)
{
	static BYTE keystate[256];
	dinkey->Acquire();
	dinkey->GetDeviceState(256, (LPVOID)keystate);
	if(keystate[DIK_W] &0x80)
		MessageBox(NULL,"W är ned tryckt?","You made it idot",MB_OK);

	return;

}

best regard Me.
Evil Steve
Evil Steve
Quote:
Original post by snoddas14
i complie it and it get no error, but then when i run it
MsVs .net ends it and get´s me an break error!
Where? And what's the exact error? Are you using the debug runtimes? Any relevant debug output?
shmeeps
shmeeps
I had a problem with this code yesterday too, the code

hr = DirectInput8Create(hInst, DIRECTINPUT_VERSION, IID_IDirectInput8, 		(void**)&din, NULL);


would always fail. I changed it to

hr = DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, 		(void**)&din, NULL);


and it compiled and ran fine.

Hope this helps.
snoddas14
snoddas14
hmm, i would i need a bit mor info to you guys.

when i komplie it i get no errors no warnings and one sucess!
but then when i runt it MSVS.net Breaks is and stop it and give me som sort of
"0x000000000 trying to get 0x000000005"
if i would be able to view a pictur of it, it would be easiyer!!
Evil Steve
Evil Steve
Quote:
Original post by snoddas14
but then when i runt it MSVS.net Breaks is and stop it and give me som sort of
"0x000000000 trying to get 0x000000005"
Where? What line does it break on? That's a a sure sign of trying to dereference a null pointer, and the line it breaks on is the line with the null pointer. You can use the debugger to look at the values of your variables and find which one is null, then you can find out why it's null (If it wasn't set up correctly, or it was released / deleted).

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.