Home > Software engineering > VB call C language interface of dynamic link library function abnormal unsigned char types, the prog
VB call C language interface of dynamic link library function abnormal unsigned char types, the prog
Time:09-23
In VB statement calls dynamic library: Private Declare Function unionUnPacked Lib "C: \ \ DLL \ DMexp ap DLL" (ByVal rxData As Long, _ ByVal rxLen As Long, _ ByVal pData As Long, _ ByVal pLen As Long As Byte)
The head of the dynamic library interface file: Unsigned char unionUnPacked (unsigned char * rxData, unsigned char rxLen, unsigned char * pData, unsigned char * pLen);
When I was in VB code using the following code, the program is abnormal exit, a great god please help analysis, isn't me in VB call dynamic library statement to return for the Byte data type? Or other reasons? StrRes=unionUnPacked (VarPtr (bytStr (0)), lngIndex, VarPtr (tempbytStr (0)), pLenth)
CodePudding user response:
The asterisk parameters, when the statement should be a statement into a ByRef Then call it without VarPtr, directly through the first element of the array, such as bytStr (0)
Private Declare Function unionUnPacked Lib "C: \ \ DLL \ DMexp ap DLL" (ByRef rxData As Byte, _ ByVal rxLen As Byte, _ ByRef pData As Byte, _ ByRef pLen As Byte) As Byte
Dim bytRetAs Byte, bytRFData (255) As Byte, bytRFLen As Byte, bytPData (255) As Byte, bytPLen As Byte