Article View: borland.public.cppbuilder.nativeapi
Article #8786Re: WM_COPYDATA problem
From: JD
Date: Tue, 14 Sep 2004 19:30
Date: Tue, 14 Sep 2004 19:30
31 lines
1587 bytes
1587 bytes
"Boba" <Boba@somewhere.world> wrote:
>
> [...] ShowMessage(s);//some strings get corrupt. Why?
Try this:
ShowMessage( IntToStr(sizeof(buff)) );
You'll see that the result falls well short of 1024 bytes.
This means that:
::ZeroMemory(buff,sizeof(buff));
is only clearing the first 4 bytes so when the string is
copied into buff, you can and will have garbage left in it
from the previouse call.
Also note that you are not accounting for the NULL terminator
of the AnsiString:
cds.cbData=AnsiStringToSend.Length();//<1024
That should be .Length() + 1;
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.
~ JD
Technical Details
Message-ID:
<414746c7$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!news.zanker.org!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<4147428c@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 From: "JD" <nospam@nospam.com> Sender: "JD" <nospam@nospam.com> Reply-To: "JD" <nospam@nospam.com> Subject: Re: WM_COPYDATA problem Newsgroups: borland.public.cppbuilder.nativeapi X-User-Info: 172.136.12.199 References: <4147428c@newsgroups.borland.com> NNTP-Posting-Host: 207.105.83.66 Message-ID: <414746c7$1@newsgroups.borland.com> Date: 14 Sep 2004 12:30:15 -0700 X-Trace: newsgroups.borland.com 1095190215 207.105.83.66 (14 Sep 2004 12:30:15 -0700) Lines: 32 Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!news.zanker.org!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail