Board index » delphi » calling DLLs (that use arrays) in Delphi from VB

calling DLLs (that use arrays) in Delphi from VB

I am having problems writing DLLs in delphi and calling then in VB.

Pascal:
library xyz(var N: array of integers); export;
begin
    N[1]=1
end;
exports
    xyz;
begin
end.
VB:
declare sub xyz lib "abc.dll" (N%)
global N()

This compiles fine. Without the array, I can run it fine in VB. When I run this, the system crashes.

Anyone - please help!

Jim Johnsen
john...@{*word*182}burg.net

 

Re:calling DLLs (that use arrays) in Delphi from VB


What Delphi are You using, What VB.

Are you compliling 16 bit and calling 32 bit????

Why not make it an ActiveX (if you've got Delphi 3).
--
+++

Use this address to Mail, no Spam_Mail.
Sanne Hoekstra
Sant...@dds.dds.nl

johnsen <john...@{*word*182}burg.net> schreef in artikel
<5n3t64$...@usenet76.supernews.com>...

Quote
> I am having problems writing DLLs in delphi and calling then in VB.

> Pascal:
> library xyz(var N: array of integers); export;
> begin
>     N[1]=1
> end;
> exports
>     xyz;
> begin
> end.
> VB:
> declare sub xyz lib "abc.dll" (N%)
> global N()

> This compiles fine. Without the array, I can run it fine in VB. When I

run this, the system crashes.

- Show quoted text -

Quote

> Anyone - please help!

> Jim Johnsen
> john...@{*word*182}burg.net

Re:calling DLLs (that use arrays) in Delphi from VB


Hi johnsen!

Quote

> I am having problems writing DLLs in delphi and calling then in VB.

> Pascal:
> library xyz(var N: array of integers); export;

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
First of all, you are using 'open array' parameter!
Secondary, you do not notified the compliler to generate 'Standard
call'.
The first problem reflects to one additional (!!!) actual parameter
known as
array size. And second problem reflects to regester-based call instead
of
stack-based.

So, you can declare your routine as follows:

procedure xyz(var N: array of integer); stdcall; export; { using Delphi
2+ }
procedure xyz(var N: array of integer); export; { using Delphi 1.0 }

and add one additional integer parameter to BASIC's routine declare. It
must be
32-bit for 32-bit VB and 16-bit interger for 16-bit VB.

Good luck.

Apology for my poor English.

Dmitry.
Moscow,RU.

Other Threads