Board index » delphi » Passing variable length VB string array to DLL and back

Passing variable length VB string array to DLL and back

How can I pass a variable length string array from VB-16 4.0 to a Delphi
1.0 DLL, process the array, and pass it back again to VB?

--
Thomas Jaeger
CZAR Software
http://www.czar.com

 

Re:Passing variable length VB string array to DLL and back


Quote
Thomas Jaeger <supp...@czar.com> wrote:
>How can I pass a variable length string array from VB-16 4.0 to a Delphi
>1.0 DLL, process the array, and pass it back again to VB?

If I remember correctly, a VB string and a Delphi String are the same.

If that is not true, VB runtime DLL contains a few functions for
converted VB strings to null terminated strings.  I do not have the
CDK for VB with me so cannot tell you the exact functions.  But I do
know that if you look in the VB control development kit, there is the
anwser.

=====================================================
Nothing is as terrible to see as ignorance in action.
[Goethe]
--
For my public PGP key, see my web page at
http://www.mindspring.com/~isoftdev/homeofmatt.html

Re:Passing variable length VB string array to DLL and back


Quote
Matt Raffel wrote:

> Thomas Jaeger <supp...@czar.com> wrote:

> >How can I pass a variable length string array from VB-16 4.0 to a Delphi
> >1.0 DLL, process the array, and pass it back again to VB?

> If I remember correctly, a VB string and a Delphi String are the same.

> If that is not true, VB runtime DLL contains a few functions for
> converted VB strings to null terminated strings.  I do not have the
> CDK for VB with me so cannot tell you the exact functions.  But I do
> know that if you look in the VB control development kit, there is the
> anwser.

Do you know where this control development kit is available? Thank you!

--
Thomas Jaeger
CZAR Software
http://www.czar.com

Re:Passing variable length VB string array to DLL and back


Quote
Thomas Jaeger wrote:

> How can I pass a variable length string array from VB-16 4.0 to a Delphi
> 1.0 DLL, process the array, and pass it back again to VB?

Thomas:

What you should probably look into are support routines for type BSTR.
BSTR's are BASIC (or binary) strings that are similar to both Pascal
and C-style strings.  From what I understand, they store the length
of the string in the 0th position -- making them similar to Pascal
strings -- yet, they contain a terminating NULL character -- making them
similar to a C-style string.  Some 16-bit support routines you might
be interested in are:

  procedure SysFreeString(bstr: BSTR);
  function SysStringLen(p1: BSTR): Cardinal;
  function SysAllocString(const p1: PChar): BSTR;
  function SysReAllocString(var p1: BSTR; const p2: PChar): Integer;
  function SysAllocStringLen(const p1: PChar; p2: Cardinal): BSTR;
  function SysReAllocStringLen(var p1: BSTR; const p2: PChar;
p3:                                         Cardinal): Integer

These are contained in the "Dispatch" unit of Delphi 1.0 (OLE2 unit for
Delphi 2.0)

You might also want to look at Variant types and their helper functions,
as well as treating BSTRs as typical PChar's, since they do contain a
terminating NULL character!

Hope this information helps,
-Jim Rofkar.

Other Threads