passing a string array to a C dll
-
Heres the synopsis:
Heres my problem:
FRom the VB I am sending:
Dim MyString(0 To 2) As String
MyString(0) = "a "
MyString(1) = "aaaa"
MyString(2) = "mmmm"
Call MyCString(MyString(0)) //I want to send in the address of the array MyString which is what I think I'm doing because:// If I had an array of ints called IntAr[0 to 5] in VB then sending in IntAR[0] means sending in the address of the array I have gathered.
============================ where:
Public Declare Sub MyCString Lib "MyProj.dll" _
Alias "?MyCString@@YGXPAD@Z" (ByVal invar As String)========== and in the C dll:
__declspec( dllexport ) void MyCString(char * invar)
{
strcpy(invar+4, "From The C Code"); // Leave first 4 characters alone & replace the rest
return;
}This makes the value of MySTring(0) = "a From The C Code" in VB because the dll did : strcpy(invar+4, "From The C Code"); But how do I change MySTring(1)in the dll ? Thx, ns Appreciate your help, ns
-
Heres the synopsis:
Heres my problem:
FRom the VB I am sending:
Dim MyString(0 To 2) As String
MyString(0) = "a "
MyString(1) = "aaaa"
MyString(2) = "mmmm"
Call MyCString(MyString(0)) //I want to send in the address of the array MyString which is what I think I'm doing because:// If I had an array of ints called IntAr[0 to 5] in VB then sending in IntAR[0] means sending in the address of the array I have gathered.
============================ where:
Public Declare Sub MyCString Lib "MyProj.dll" _
Alias "?MyCString@@YGXPAD@Z" (ByVal invar As String)========== and in the C dll:
__declspec( dllexport ) void MyCString(char * invar)
{
strcpy(invar+4, "From The C Code"); // Leave first 4 characters alone & replace the rest
return;
}This makes the value of MySTring(0) = "a From The C Code" in VB because the dll did : strcpy(invar+4, "From The C Code"); But how do I change MySTring(1)in the dll ? Thx, ns Appreciate your help, ns
ns wrote: But how do I change MySTring(1)in the dll ? I think you can increment the address position, something like this, however I know the following doesn't work exactly how you need it to. This atleast provides the idea.
Show(int* x)
{
int* y;
cout *x << endl;
y = x += sizeof(int);
cout << *y << endl;
}
Nick Parker
You see the Standards change. - Fellow co-worker