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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,529481ac2d77d9f6 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.germany.com!newsfeed-0.progon.net!progon.net!newsfeed.ision.net!newsfeed2.easynews.net!ision!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Translating a VB dll header to Ada Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1176320910.543255.74730@b75g2000hsg.googlegroups.com> <1176387466.525266.257670@n59g2000hsh.googlegroups.com> <1iye22k0o4obx$.naanhqgipkpf.dlg@40tude.net> <1176477928.918685.283010@b75g2000hsg.googlegroups.com> <1176512718.219589.63270@w1g2000hsg.googlegroups.com> <13poyps5u5uo8$.rzkmixdov6tr.dlg@40tude.net> <1176552993.629014.137900@y80g2000hsf.googlegroups.com> Date: Sat, 14 Apr 2007 17:30:57 +0200 Message-ID: <4tn69i24hl6w$.ns08mtjy7afs.dlg@40tude.net> NNTP-Posting-Date: 14 Apr 2007 17:30:03 CEST NNTP-Posting-Host: 01fcd89d.newsspool4.arcor-online.net X-Trace: DXC==0fYNLWOI3ef1oJaJ0@dmg4IUK On 14 Apr 2007 05:16:33 -0700, vienapl@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. Kazakov http://www.dmitry-kazakov.de