C Board  

Go Back   C Board > Platform Specific Boards > Windows Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 11-07-2001, 01:43 PM   #1
Registered User
 
Strider's Avatar
 
Join Date: Aug 2001
Posts: 149
0xC0000005: Access Violation

I keep running in Access Violations while running through the DirectX 8 Init functions. Here is an example where I receive an 0xC0000005: Access Violation. Any one have an idea of what may be the cause?
Code:
// directinput globals
LPDIRECTINPUT8       lpdi      = NULL;    // dinput object
LPDIRECTINPUTDEVICE8 lpdikey   = NULL;    // dinput keyboard

int DInput_Init_Keyboard(void)
{
	// this function initializes the keyboard device

	// create the keyboard device  
        // get 0xC0000005: Access Violation here 
	if (lpdi->CreateDevice(GUID_SysKeyboard, 
			&lpdikey, 
			NULL) != DI_OK)
	{
		return(0);
	}

	// set cooperation level
	if (lpdikey->SetCooperativeLevel(main_window_handle, 
				DISCL_NONEXCLUSIVE | 
				DISCL_BACKGROUND) != DI_OK)
	{
		return(0);
	}

	// set data format
	if (lpdikey->SetDataFormat(&c_dfDIKeyboard)!=DI_OK)
		return(0);

	// acquire the keyboard
	if (lpdikey->Acquire()!=DI_OK)
		return(0);

	// return success
	return(1);
} // end DInput_Init_Keyboard
Thanks,
David
__________________
One Ring to rule them all, One Ring to find them,
One Ring to bring them all and in the darkness bind them
In the Land of Mordor where the Shadows lie.
Strider is offline   Reply With Quote
Old 11-07-2001, 02:02 PM   #2
zen
of Zen Hall
 
zen's Avatar
 
Join Date: Aug 2001
Posts: 1,007
Does lpdi point to a valid DirectInput object?
__________________
zen
zen is offline   Reply With Quote
Old 11-07-2001, 02:20 PM   #3
Registered User
 
Strider's Avatar
 
Join Date: Aug 2001
Posts: 149
I initialize it with this function:
Code:
int DInput_Init(void)
{
	// this function initializes directinput

	if(FAILED(DirectInput8Create(g_hinst,
				DIRECTINPUT_VERSION,
				IID_IDirectInput8,
				(void **)&lpdi,
				NULL)))
	{
		return(0);
	}

	// return success
	return(1);
} // end DInput_Init
It seems to fail and return 0 here. When lpdi is referenced again it has a NULL value (0xC0000000). How can I correct this?

David
__________________
One Ring to rule them all, One Ring to find them,
One Ring to bring them all and in the darkness bind them
In the Land of Mordor where the Shadows lie.
Strider is offline   Reply With Quote
Old 11-07-2001, 02:46 PM   #4
Registered User
 
Strider's Avatar
 
Join Date: Aug 2001
Posts: 149
I believe I found my error. I was saving the HINSTANCE by declaring:
extern HINSTANCE main_instance;

But I was using:
HINSTANCE hinstance_app;

to save the instance in my driver program.

Thanks for the help,
David
__________________
One Ring to rule them all, One Ring to find them,
One Ring to bring them all and in the darkness bind them
In the Land of Mordor where the Shadows lie.
Strider is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Access violation... can't figure it out... Raigne C++ Programming 7 10-11-2007 10:52 AM
access violation in int array George2 C Programming 2 08-02-2007 11:28 PM
Copying memory, pointers and the like. psychopath C++ Programming 34 12-12-2006 01:37 PM
FtpFileFind access violation with MS VC++ 6.0 earth_angel C++ Programming 3 09-22-2005 07:02 PM
First-chance exception in app.exe (KERNEL32.DLL): 0xC0000005: Access Violation. beyonddc Windows Programming 5 07-13-2003 01:01 PM


All times are GMT -6. The time now is 05:24 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22