![]() |
| | #1 |
| Registered User Join Date: Aug 2001
Posts: 149
| 0xC0000005: Access Violation 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
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 | |
| | #2 |
| of Zen Hall Join Date: Aug 2001
Posts: 1,007
| Does lpdi point to a valid DirectInput object?
__________________ zen |
| zen is offline | |
| | #3 |
| Registered User 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
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 | |
| | #4 |
| Registered User 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 | |
![]() |
| Thread Tools | |
| Display Modes | |
|
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 |