From: steve.woodward@uk.thalesgroup.com (Steve Woodward)
Subject: Calling DLL created with Aonix Object Ada from Visual Basic
Date: 18 Jul 2002 02:56:48 -0700
Date: 2002-07-18T09:56:48+00:00 [thread overview]
Message-ID: <db2921a9.0207180156.4c49e39f@posting.google.com> (raw)
I have some Ada code that needs to be run from a MS Access front end.
The plan is to link the Ada code as a DLL, then call the DLL from VB
code in Access.
Parameter passing is proving difficult. I have got integers to work
(both directions) but not booleans, strings or arrays of integers.
From previous articles I learned that I should be using the parameter
passing convention DLL_Stdcall.
This is the Ada for for a function that returns the sum of two
integers:
function DLLSumOf (X: Integer; Y: Integer) return integer;
pragma Export(DLL_Stdcall,DLLSumOf,"DLLSumOf");
-- next line is required according to
www.tertullian.org/rpearse/ada_dll.htm
pragma Suppress (All_checks, on => DLLSumOf);
I used the MS utilty "Dependency Walker" to look inside the DLL I
created, and found it had the function name "_DLLSumOf@8". So this is
the Alias name that I put into the VB declaration, as follows:
Private Declare Function DLLSumOf Lib
"H:\Ada\tryitout\AddThem\AddThem-Win32(Intel)-Debug\dll.dll" _
Alias "_DLLSumOf@8" (ByVal X As Integer, ByVal Y As Integer) As
Integer
This works! Now using the same technique I tried a function that does
nothing more than return a boolean set to false. VB puts the returned
value in a check box.
Ada:
function ReturnFalse return boolean;
pragma Export(DLL_Stdcall, ReturnFalse,"ReturnFalse");
pragma Suppress (All_checks, on => ReturnFalse);
VB:
Private Declare Function ReturnFalse Lib
"H:\Ada\tryitout\AddThem\AddThem-Win32(Intel)-Debug\dll.dll" _
Alias "_ReturnFalse@0" () As Boolean
When I run this, the check box becomes "true", not "false" as
expected. When I tried to pass a boolean IN to a function, the result
implied that the DLL saw it as "true" even when the VB had set it to
"false".
Can anybody spot what I am doing wrong?
How do I pass strings?
How do I pass arrays of integers??
Is it possible to pass user-defined types which include arrays???
Steve Woodward
next reply other threads:[~2002-07-18 9:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-07-18 9:56 Steve Woodward [this message]
2002-07-18 11:47 ` Calling DLL created with Aonix Object Ada from Visual Basic Larry Hazel
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox