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)

CodePudding user response:

Unsigned char unionUnPacked (unsigned char * rxData, unsigned char rxLen, unsigned char * pData, unsigned char * pLen);

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

BytRet=unionUnPacked (bytRFData (0), bytRFLen, bytPData (0), bytPLen)

CodePudding user response:

refer to the second floor of123 response:
unsigned char unionUnPacked (unsigned char * rxData, unsigned char rxLen, unsigned char * pData, unsigned char * pLen);

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

BytRet=unionUnPacked (bytRFData (0), bytRFLen, bytPData (0), bytPLen)


reference 1st floor bakw 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)



Changed the test and submit them to the vb. 6 application errors, 0 0 x00000000 memory x0faf7899 instruction references, this memory cannot be read,

CodePudding user response:

Don't be A language code is modified to B language code busywork,
Also don't use A language code to directly invoke B language code base, this complicated things so easy to get wrong,
Just make A, B language code of input and output is redirected to A text file, or modify A, B language code let it through text file input and output,
Can easily make A, B coordination between the two languages,
For example:
A will request data written to A file a.t xt, renamed after finish aa. TXT
B find aa. TXT, read its contents, call the corresponding function, and writes the results file b.t xt, after finish delete aa. TXT, changed its name to bb. TXT
Found A bb. TXT, read the content, after finish delete bb. TXT
Above can be replaced by any kind of A language or development environment, B can be replaced by any kind of with the development of A different language or development environment,
Unless A or B does not support to determine whether A file exists, file read and write and file name,
But who can name does not support to determine whether a file exists, file read and write and file name for the development of language or development environment?
Can put the temporary files on the RamDisk efficiency decrease wear disk,
Data structure is very complex, a text file format problems refer to a json or XML

The communication methods between the temporary text file sharing this process there are plenty of advantages, compared to other method only listed below I can think of now:
Loose coupling between process,
Can be on the same machine, process, also can cross machine, across the operating system, hardware platform, and even multinational,
, convenient debugging, and monitoring, only let the third party or artificial view the temporary text files,
Switch, convenient online service, need to delete or create the temporary text files,
, is convenient to realize distributed and load balancing,
Services to provide convenient, queue, queue is full and it is almost impossible to happen (unless the hard disk space full)
DE...

"Across different languages, machine, across the operating system, hardware platform, multinational, cross *. *" misery,
Back is "the use of Shared a plain text file information communication" of the shore!

CodePudding user response:

Is the right address,,,,,,, right, does not know what the function name is stdcall C function,,,
  • Related