From: Larry Hazel <lhhazel@otelco.net>
Subject: Re: Calling DLL created with Aonix Object Ada from Visual Basic
Date: Thu, 18 Jul 2002 06:47:32 -0500
Date: 2002-07-18T06:47:32-05:00 [thread overview]
Message-ID: <3D36AAD4.7010404@otelco.net> (raw)
In-Reply-To: db2921a9.0207180156.4c49e39f@posting.google.com
Steve Woodward wrote:
> 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
Could there be a difference (size or bit pattern) between the VB and Ada
representation of true and false?
Larry
prev parent reply other threads:[~2002-07-18 11:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-07-18 9:56 Calling DLL created with Aonix Object Ada from Visual Basic Steve Woodward
2002-07-18 11:47 ` Larry Hazel [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox