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-Thread: 103376,47957cb8c33729e5 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!wns13feed!worldnet.att.net!attbi_s04.POSTED!53ab2750!not-for-mail From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: Thick Ada bindings to C Win32 References: X-Newsreader: Tom's custom newsreader Message-ID: NNTP-Posting-Host: 67.161.24.234 X-Complaints-To: abuse@comcast.net X-Trace: attbi_s04 1100061396 67.161.24.234 (Wed, 10 Nov 2004 04:36:36 GMT) NNTP-Posting-Date: Wed, 10 Nov 2004 04:36:36 GMT Organization: Comcast Online Date: Wed, 10 Nov 2004 04:36:36 GMT Xref: g2news1.google.com comp.lang.ada:6101 Date: 2004-11-10T04:36:36+00:00 List-Id: > procedure Put(Handle : Handle_Type; Item : in Byte_Array) is > > ... > > Buffer : aliased Byte_Array := Item; > > A : Interfaces.C.Strings.Char_Array_Access > := Convert_Byte_Array_Ptr_To_Char_Array_Ptr(Buffer'Unchecked_Access); > > B : Interfaces.C.Strings.Chars_Ptr > := Interfaces.C.Strings.To_Chars_Ptr(A,False); > > Buffer_Ptr : Win32.Lpcvoid > := Convert_Chars_Ptr_To_Lpcvoid(B); > > begin > Bool_Result := > Win32.Winbase.WriteFile > ( ... > lpBuffer => Buffer_Ptr, -- Win32.Lpcvoid > nNumberOfBytesToWrite => Win32.Dword(Item'Length), -- Win32.Dword => 1 bytes > ... ) > > end Put; > > While the get function is OK, I think the put function is horrible. Did you try: function WriteFile(... Item : in Byte_Array; nNumberOfBytesToWrite : in Win32.DWord, ...) return c_bool; pragma Import(StdCall, WriteFile, "WriteFile"); procedure Put(Handle : Handle_Type; Item : in Byte_Array) is ... begin Bool_Result := Win32.Winbase.WriteFile ( ... Item => Item, nNumberOfBytesToWrite => Win32.Dword(Item'Length), ... ) end Put;