About C do dynamic library function called out the problem
Time:09-15
Example: the dynamic library is int ABC (int a, b unsigned char *, unsigned char * c, int * d)
Into ginseng is a, b 11 bytes (agreement) and is c, d key is out and did not say how many bytes, d value is cc number of bytes ()
I am such statement Public Declare Function JM Lib "TZhuZhanDLL. DLL" (ByVal a As Long, _ ByRef b As Byte, _ ByRef c As Byte, _ ByRef d As Long As Long)
Use it, how how to define the d, I know the address, the d is also dim forD as long like this?
Dim aa as long Dim bb (10) as byte 'convention is 11 bytes Dim cc () as byte ' without the agreementDim dd as long 'not agreed, this value is that the cc number of bytes ()
Aa=1 For I=0 to 10 Bb (I)=I + 10 'I literally got Next Bb ( The select case JM ((0) aa, bb, cc (0), dd) Case 0 'success Case1 'failure End the select
Now another run to VB tore rout out of here, my monitor can monitor, I don't know is that in a dynamic library without showing the number of bytes refs, how to value, how to define the d, use byref?
CodePudding user response:
According to the "prototype", your API in VB6, the statement and the corresponding call way is no problem in theory,
But the parameter c is for the use of "output", its function description, there should be a "need to how much space", How much space or how to "get" instructions (such as c to NULL) yeah,
On the other hand, however, your VB code, cc () is a dynamic array. When you call API "before using" did not assign data space, Should be "subscript crossing the line" a runtime error to ah, how is the process of "crash"! Really a little don't understand...
In addition, in the current "is not clear how much", according to your application scenario, should also not use a lot of space, Then you can be allocated a "very rich" space to give it a try... Before calling the API, such as redim cc (1023) or redim cc (4095), and so on, And see if I can perform well,
If you can run normally, and see how it is used in space; Is "fixed size" or change (what do you want to use different "input number" test), If the fixed allocation according to the actual needs; If change, the use of a "than the maximum slightly larger number of space,