
Problem passing arrays of strings to C DLL
I'm having problems passing an array of strings to a C DLL. The first
element of the array appears OK in the dll while the remaining elements
result in garbage or an access violation. This DLL function must also
be callable from C (which works). I've included code snippets below.
Any help would be greatly appreciated, including pointing me to
examples.
Thanks in advance,
Gerald Aden
THE VB CODE
Private Declare Function foo Lib "test.dll" (ByRef sNames As String) As
Long Public Sub callfoo() As Long
Dim data(0 to 2) As String * 128
data(0) = "person1"
data(1) = "person2"
data(2) = "person3"
foo data(0)
End Sub
THE C CODE
extern "C" long WINAPI foo(char* names[])
{
int i;
for (i = 0; i <= 2; i++) {
printf("Name[%d] = %s", i, names[i]);
}
Quote:
}
Sent via Deja.com http://www.*-*-*.com/
Share what you know. Learn what you don't.