From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8f27a823d2278175 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-07-18 04:47:10 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!news.maxwell.syr.edu!news-out.nuthinbutnews.com!propagator-sterling!news-in.nuthinbutnews.com!falcon.america.net!eagle.america.net.POSTED!not-for-mail Message-ID: <3D36AAD4.7010404@otelco.net> From: Larry Hazel User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.0rc2) Gecko/20020618 Netscape/7.0b1 X-Accept-Language: en,x-ns11F8K63r3NhQ,x-ns2r2e09O MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Calling DLL created with Aonix Object Ada from Visual Basic References: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 18 Jul 2002 06:47:32 -0500 NNTP-Posting-Host: 66.0.32.230 X-Trace: eagle.america.net 1026992824 66.0.32.230 (Thu, 18 Jul 2002 07:47:04 EDT) NNTP-Posting-Date: Thu, 18 Jul 2002 07:47:04 EDT Organization: 24hoursupport.com Xref: archiver1.google.com comp.lang.ada:27217 Date: 2002-07-18T06:47:32-05:00 List-Id: 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