我的应用程序有 CAN Dll 程序,它是单独使用的。现在我已将 Drivers 程序包含在我的应用程序中,但我遇到了这个错误System Access Violation Exception:Attempted to read or write protected memory
。错误有什么用?我附上了引发此错误的 Dll 代码和应用程序代码。
CAN Dll 代码
int receive_data(unsigned char *data_output, int *MsgId, XLportHandle g_xlPortHandle){
XLstatus xlStatus, xlStatus_new;
XLevent xlEvent;
unsigned int msgsrx=RECEIVE_EVENT_SIZE;
char *local_data ="11111111";
DWORD status;
xlStatus_new = xlSetNotification(g_xlPortHandle, &h, 1);
WaitForSingleObject(h,1);
xlStatus = XL_SUCCESS;
while(!xlStatus){
msgsrx = RECEIVE_EVENT_SIZE;
xlStatus = xlReceive(g_xlPortHandle, &msgsrx, &xlEvent);---------->Here is the error
if ( xlStatus!=XL_ERR_QUEUE_IS_EMPTY ) {
memcpy(data_output,xlEvent.tagData.msg.data,8);
*MsgId = xlEvent.tagData.msg.id;
return 0;
}
else{
return XL_ERR_QUEUE_IS_EMPTY;
}
}
}
所以这个程序成功构建并且在执行它时我得到了错误
Receive thread quit Unexpectedly
system Access violation Exception:Attempted to read or write protected memory.This is often an indication that other memory is corrupt at
xlreceive(int32,Uint32*,s_xl_event*)
at receive_data(Byte*data_output,int32*MsgId,Int32 g_xlPortHandle).