
function parameters to pass a VB string array to a C++ DLL
Well, it seems that I'm going to pass a single string instead of my array.
But I must admit, it's a little bit frustrating.
I thought I would achieve this without much problems, but it's not the
case...
However, now the question is : if I fill my array with a few thousands
strings and make a call to my dll function a thousand times, won't this take
more time, than just calling my Dll function once and passing a single array
?
I know VB and I like C++, it would be so great if I could work with both...
Anyway, thank you very much. And if you get any idea, tell me. I think the
problem is interesting.
Best Regards,
PaCo.
Quote:
> My guess would be to use BSTR on the C side, since this is the type of
> string that VB uses. And ByRef in the VB call. VC/VB does provide built
in
> conversion between VB String and C char*, however when you want to pass an
> array of them I don't think it will recognize them. Since you do have
> overhead of DLL function call I'm not too sure that you will achieve speed
> improvement calling an external DLL.
> I have had little success when trying to pass complex user defined types
> between VB and VC, and would recommend that if you can't get it working in
a
> day or so, switch to passing a single string, instead of an array of
> them...or just code it in VB.
> I would guess that the following will probably also not work...
> OPARRAY_API bool __stdcall testVBArray(BSTR *pszArray);
> Private Declare Function testVBArray Lib "OPArray.dll" (ByRef
> pszVBArray() As String) As Long
> > Hi Aaron,
> > I'm working on creating some DLLs to improve the speed of my VB
> > applications.
> > So, I try to make a C++ function which accepts a string array, modifies
> some
> > values in my array and return true or false whether everything went fine
> or
> > not during the process.
> > So, after reading articles in the MSDN Library I thought everything
would
> > just run fine. But the point is that I'm getting just nowhere.
> > My question is : could you show me some C++ function prototype which
> accepts
> > a string array from VB. I just want to know what is wrong with the
> following
> > :
> > C++ function :
> > OPARRAY_API bool __stdcall testVBArray(LPSTR pszArray)
> > VB API Call:
> > Private Declare Function testVBArray Lib "OPArray.dll"
(pszVBArray()
> As
> > String) As Long
> > VB function Call:
> > Sub main()
> > Dim myarray(0 To 2) As String
> > myarray(0) = "John"
> > myarray(1) = "Doe"
> > MsgBox "The result is : " & Cstr(EmptyCell(myarray(0)))
> > End Sub
> > and if it's not wrong, how can I get the values in the C++ function?
> > Thanks,
> > Paco
message
> > > Probably you don't want to pass a char array, but a pointer to a char
> > array.
> > > Whether you have to use LPSTR or SAFEARRAY depends on the DLL and its
> > header
> > > files. If you post some code, we might be able to help you.
> > > Regards,
> > > Aaron Isotton
> > > > Hi there,
> > > > I want to pass a string array to a C++ DLL, but i don't know which
> > > parameter
> > > > I have to use...
> > > > Is it :
> > > > LPSTR myArray or something with SAFEARRAY or something else?
> > > > Sincerely, Paco