From: vienapl@hotmail.com
Subject: Re: Translating a VB dll header to Ada
Date: 14 Apr 2007 14:37:07 -0700
Date: 2007-04-14T14:37:07-07:00 [thread overview]
Message-ID: <1176586627.612504.176470@n76g2000hsh.googlegroups.com> (raw)
In-Reply-To: <4tn69i24hl6w$.ns08mtjy7afs.dlg@40tude.net>
That is the correct answer, it works!
Thank you a lot Philippe and Dmitry.
However, now I'm having trouble with the
procedure CKHSendString (helper : System.Address; data : in
Interfaces.C.Char_Array);
pragma Import (C, CKHSendString, External_Name => "CKHSendString");
function. It doesn't raise an exception, but it does not seem to do
anything at all. It works fine when used from the VB6 or C++ samples.
Thank you so much, again.
On Apr 14, 5:30 pm, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
wrote:
> On 14 Apr 2007 05:16:33 -0700, vien...@hotmail.com wrote:
>
> > Yes, it does work with only those two functions.
>
> > I don't know which parameter could be wrong on the CTHSetText
> > function. If I change a Char_Array for a WChar_Array I get a raised
> > PROGRAM_ERROR : EXCEPTION_ACCESS_VIOLATION instead, but the debugger
> > prompts the same message.
>
> OK, C++ code you have referred to, looks quite ..., so let me suggest a bit
> offending thing. What if they copy pointers to strings?
>
> So what happens if you allocate the string passed to CTHSetText statically:
>
> Object_Text : Interfaces.C.Char_Array :=
> Interfaces.C.To_C ("Object");
> begin
> ...
> CTHSetText (TextHelperID, Object_Text);
> -- CTHSetText remembers a pointer to Object_Text, which has to
> -- exist as long as the library may dereference it
> ...
>
> Another suggestion. If CTHSetText actually takes a pointer to a dynamically
> allocated string which will be freed later somewhere inside the library.
> Then CTHSetText should be declared like this:
>
> procedure CTHSetText
> (Helper : System.Address; Name_Ptr : Interfaces.C.Strings.chars_ptr);
> pragma Import (C, CTHSetText, ...);
>
> and used as:
>
> CTHSetText (TextHelperID, Interfaces.C.Strings.New_String ("Object"));
> -- CTHSetText takes care of the memory allocated
>
> --
> Regards,
> Dmitry A. Kazakovhttp://www.dmitry-kazakov.de
next prev parent reply other threads:[~2007-04-14 21:37 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-11 19:48 Translating a VB dll header to Ada vienapl
2007-04-12 8:06 ` Dmitry A. Kazakov
2007-04-12 14:17 ` vienapl
2007-04-12 17:16 ` Dmitry A. Kazakov
2007-04-13 15:25 ` vienapl
2007-04-13 16:55 ` Dmitry A. Kazakov
2007-04-14 1:05 ` vienapl
2007-04-14 7:17 ` Dmitry A. Kazakov
2007-04-14 12:16 ` vienapl
2007-04-14 14:01 ` Philippe Bertin
2007-04-14 15:30 ` Dmitry A. Kazakov
2007-04-14 21:37 ` vienapl [this message]
2007-04-15 14:03 ` vienapl
2007-04-15 15:32 ` Dmitry A. Kazakov
2007-04-18 18:47 ` Tarjei T. Jensen
2007-04-12 11:34 ` gautier_niouzes
2007-04-12 14:24 ` vienapl
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox