Another problem is that you are also not allocating data for the packet before calling API_OBDII_Mode1_GetPacket.
You should add this stuff to your .bas file first:
Code:
Public Const API_OBDII_NUMHEADERBYTES = 3
Public Const API_OBDII_NUMDATABYTES = 7
Type API_OBDII_MSGPACKET
m_dwTimeRecieved As Long
m_iNumDataBytes As Byte
m_Header(API_OBDII_NUMHEADERBYTES) as Byte
m_Data(API_OBDII_NUMDATABYTES) as Byte
End Type
Then you should declare lpMsgPacket as API_OBDII_MSGPACKET rather then longi.e.
Code:
Dim lpMsgPacket As API_OBDII_MSGPACKET
Also change the API_OBDII_Mode1_GetPacket declaration to reflect this and pass it in ByRef.
Code:
Public Declare Sub API_OBDII_Mode1_GetPacket Lib "OBDIIFaker.dll" (ByVal lpUser As Long, ByVal eOBDPID As Long, ByRef lpMsgPacket As API_OBDII_MSGPACKET)
To interpret the data in the packets you'll have to use the helper functions or port them to your own in VB.
This is why your program was crashing.