Article View: borland.public.cppbuilder.nativeapi
Article #8787Re: WM_COPYDATA problem
From: Hans Galema
Date: Tue, 14 Sep 2004 19:50
Date: Tue, 14 Sep 2004 19:50
32 lines
1959 bytes
1959 bytes
JD wrote: > ShowMessage( IntToStr(sizeof(buff)) ); > > You'll see that the result falls well short of 1024 bytes. No. It will show 1024 as buff is defined as "char buff [1024];". > Also note that you are not accounting for the NULL terminator > of the AnsiString: > cds.cbData=AnsiStringToSend.Length();//<1024 > > That should be .Length() + 1; In general that would be a good idea. But it is not needed here when indeed Length() < 1024. > Fix either of these and it will work but you should fix both > and add code to make sure that the sending string length is > never greater than 1023 because it needs the extra for the > NULL terminator. The 0 terminator is always there as buff is first filled with 1024 zero's. What could be the problem is that the c_str() pointer is not valid during the call of SendMessage. Better copy the content of that AnsiString in a local char buffer and send the char buffer. Hans. an
Technical Details
Message-ID:
<41474af0@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.frii.net!newsfeed.frii.net!news.compaq.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<4147428c@newsgroups.borland.com> <414746c7$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,2368611c57840a13 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Tue, 14 Sep 2004 21:50:59 +0200 From: Hans Galema <dontusethis@dontusethis.nl> User-Agent: Mozilla Thunderbird 0.7 (Windows/20040616) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: WM_COPYDATA problem References: <4147428c@newsgroups.borland.com> <414746c7$1@newsgroups.borland.com> In-Reply-To: <414746c7$1@newsgroups.borland.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 129.125.201.248 Message-ID: <41474af0@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1095191280 129.125.201.248 (14 Sep 2004 12:48:00 -0700) Lines: 32 Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.frii.net!newsfeed.frii.net!news.compaq.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail