comp.lang.ada
 help / color / mirror / Atom feed
From: axtens <Bruce.Axtens@gmail.com>
Subject: Re: Access to data indirection (newbie)
Date: Tue, 27 Nov 2007 19:04:28 -0800 (PST)
Date: 2007-11-27T19:04:28-08:00	[thread overview]
Message-ID: <a8dccef6-0e1b-434a-9bb0-a34af01006df@d4g2000prg.googlegroups.com> (raw)
In-Reply-To: m263znjppf.fsf@mac.com

On Nov 28, 7:20 am, Simon Wright <simon.j.wri...@mac.com> wrote:
> Martin Krischik <krisc...@users.sourceforge.net> writes:

Well, anyway, I figured out a solution to my question, after reading
the "Summary of Operations on Access Values" in Feldman's "Software
Construction and Data Structures with Ada 95."

For ages I couldn't figure out why I felt a prompting to pick this
book up at a booksale in the local library. Now I think I know what
God was up to.

Nevertheless, thanks to both of you for adding your two bob's worth to
the mix. What I've ended up with, at least this far in, is:

VB6:
  Declare Function handlepointer Lib "release\api.dll" (ByVal x As
Long) As Long
  Dim i As Long
  i = 1001
  Debug.Print VarPtr(i)
  Debug.Print handlepointer(VarPtr(i))

Output:
 1309644
 1001

Api.ads (part of):
   function HandlePointer (
       Left : in     Win32.LONG)
   return Win32.LONG;
   ...
   pragma Export (DLL, HandlePointer );

Api.adb (part of):
   function HandlePointer (
         Left : in     Win32.LONG)
     return Win32.LONG is

      type LongRec is
         record
            L : Win32.LONG;
         end record;

      type PointerToLongRec is access LongRec;

      function Conv is
      new Unchecked_Conversion (Win32.LONG, PointerToLongRec );

      PLongRec : PointerToLongRec;
   begin
      PLongRec := Conv(Left);
      return PLongRec.All.L;
   end HandlePointer;

Kind regards,
Bruce.




  reply	other threads:[~2007-11-28  3:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-27  7:10 Access to data indirection (newbie) axtens
2007-11-27  8:11 ` Martin Krischik
2007-11-27 17:32   ` Martin Krischik
2007-11-27 22:20   ` Simon Wright
2007-11-28  3:04     ` axtens [this message]
2007-11-28  3:45       ` axtens
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox