So far I've achieved it, to a certain extent, with ObjectAda and GNAT/GPL. The code for the ObjectAda implementation is below. I'll post the GNAT/GPL stuff in the next couple of days, God willing.
BO_DLib.adb, BO_D.adb and BO_D.ads are all based, albeit rather loosely, on sample files in winapi\samples\petzold\ch19\edrlib\
First up, BO_DLib.adb
Next, the spec file, BO_D.ads
There are six routines:
- procedure Bob1 calls dobox to show a messagebox.
- function Bob2 returns a long value, 1.
- function Bob3 receives a long and adds 21 to it.
- procedure Bob4 receives a long pointer to a string and passes it to dobox for display.
I can pass Unicode to it and have it rendered appropriately.
- function Bob5 receives a long pointer to a string and returns a long being the length of the string.
- function Bob6 receives a long pointer to a string and catenates a string to it.
"Danger, Will Robinson!" ... this is not how to do it and VB complains bitterly.
And, finally, BO_D.adb, where the definitions given in BO_D are fleshed out.
Now the VB code. Take note of a few things:
- I declared the functions and procedures as DLL_Stdcall in BO_D.ads so the routines come in decorated, thus the use of Alias in the Declare line. I used Microsoft's Dependency Walker to discover to what extent the names had been mangled.
- A reference to SCRRUN.DLL was added to the project, making possible the use of the FileSystemObject.
- Bob6 barges past the limit set for the string by VB, so things get a bit unstable. I'm still working through how to pass strings back.
By the way, if you think my code sucks, say so. I'm a total newb when it comes to Ada. Critiques are always welcome. King Solomon said, "The wise person accepts instructions." and also "Better is open rebuke than hidden love."
© Copyright Bruce M. Axtens., 2007