* Calling DLL created with Aonix Object Ada from Visual Basic
@ 2002-07-18 9:56 Steve Woodward
2002-07-18 11:47 ` Larry Hazel
0 siblings, 1 reply; 2+ messages in thread
From: Steve Woodward @ 2002-07-18 9:56 UTC (permalink / 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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Calling DLL created with Aonix Object Ada from Visual Basic
2002-07-18 9:56 Calling DLL created with Aonix Object Ada from Visual Basic Steve Woodward
@ 2002-07-18 11:47 ` Larry Hazel
0 siblings, 0 replies; 2+ messages in thread
From: Larry Hazel @ 2002-07-18 11:47 UTC (permalink / raw)
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-07-18 11:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox