Passing string arrays to DLL (32 bit) 
Author Message
 Passing string arrays to DLL (32 bit)

We are trying to write an application in VB 4.0 (32 Bit) that can pass
an array of structures containing a string to a MSVC++ 4.0 DLL. When we
look at the result only the string in the 1st structure of the array
shows up. The rest looks like uninitialized memory. The DLL works if we
use a C program to pass the array of structures. Could it be that we
are using a String instead of Byte in VB?

Has anybody tried something similar & been sucessful. Any help would
be GREATLY appreciated

                        thanx in advance

                        Rich

'************************  VB Program *******************************

'String arrays should be passed as structure arrays to C
Type StructElem
    'strings passed to c should be fixed length
    StructOccur As String * 40
End Type

' Declare function in Dll
Declare Sub CStrArrayCat Lib
"Y:\VC\VBCALLS\C\CCALLS32\DEBUG\CCALLS32.DLL" (StrArr As StructElem)

Private Sub cmdStrArrayCat_Click()

    Static structArray(4) As StructElem  ' create array of structures

    structArray(0).StructOccur = "abnc"         ' Init array
    structArray(1).StructOccur = "Testing"
    structArray(2).StructOccur = "today"

   'call c routine in DLL
    CStrArrayCat structArray(0)

End Sub

******************   C  DLL Program **************************

// C structure
typedef struct
{
        char szStructOccur[40];

Quote:
} StringStructType;

// DLL function being passed the array of structures
__declspec( dllexport ) void CStrArrayCat(StringStructType
*pStructArray)


Sat, 25 Jul 1998 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Problem passing VB4 32-bit string to DLL

2. Problem passing VB4 32-bit string to DLL

3. How to create 32-bit DLL in Watcom C and call from 32-bit VB

4. TIME TO WIN 32-Bit DLL for VB 4.0 32-Bit or Higher (VB5)

5. Calling a user-written 32-bit dll from 32-bit vb 4.0

6. Calling 32-bit DLL function from 32-bit VB4 app

7. 16 bit dll and 32 bit dll

8. Migrating 16-bit ODBC DLL (SQLServer) to 32-bit ODBC DLL (MS Access)

9. Passing a user defined type ByVal to an 32-Bit DLL with VB 5

10. Passing a user defined type byval to an 32-Bit.dll

11. 32-bit Dll's for copying arrays etc

12. Search for: Vantage Power Strings DLL (32 bit)

 

 
Powered by phpBB® Forum Software