Article View: borland.public.cppbuilder.nativeapi
Article #8482Re: SendMessage problem
From: Ed Mulroy [TeamB]
Date: Mon, 18 Oct 2004 12:15
Date: Mon, 18 Oct 2004 12:15
62 lines
2800 bytes
2800 bytes
As I read it you are doing this:
Program A
fills a buffer with data
sends a message to Program B with the address of the data
Doing it that way is documented to have a problem. The programs under
Windows use virtual memory, and the numeric value of an address is
unique to the program using it so will not be valid if another program
uses it.
A method provided for doing what you describe is to use the
WM_COPYDATA message. Upon seeing that message Windows arranges for
the receiver to be given an address in its virtual memory space which
points a data area containing what you sent.
Look up the message WM_COPYDATA in the Windows help and I think your
problem will be solved.
. Ed
> Ray wrote in message
> news:4173ab7d@newsgroups.borland.com...
> Hi
>
> I am trying to send data between two applications using windows
> messages. For the purposes of testing I have
>
> In the sender application (launched by the receiver with Handles and
> msg values sent in the command line) I have
>
> static unsigned short tempbuffer[200];
>
> memcpy(&tempbuffer, buffptr,100*sizeof(short)); //buffptr points
> to the source data
>
> Debug<<*tempbuffer<<" "<<*(tempbuffer+1)<<" "
> <<*(tempbuffer+2)<<endl;
>
> SendMessage(myHandle,mymsg,0,(LPARAM)&tempbuffer);
>
> I check on the first three data values with the Debug file
>
> In the receiver I have a response table which invokes
>
> LRESULT CmBufferDone(WPARAM ident,LPARAM buff)
>
> {
>
> static unsigned short tempbuffer[200];
>
> memcpy(&tempbuffer, (unsigned short*)&buff,100*
> sizeof(short));
>
> Debug<<*tempbuffer<<" "<<*(tempbuffer+1)<<" "
> <<*(tempbuffer+2)<<endl;
>
> }
>
> When I run the two aplications, I get columns of 3672 74 64292 in
> the receiver, whereas I am sending 2048 2047 2048. Where am I going
> wrong?
Technical Details
Message-ID:
<4173b404$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<4173ab7d@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,f5a1aef685366ed1 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Ed Mulroy [TeamB]" <dont_email_me@invalid.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <4173ab7d@newsgroups.borland.com> Subject: Re: SendMessage problem Date: Mon, 18 Oct 2004 08:15:53 -0400 Lines: 64 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-RFC2646: Format=Flowed; Response NNTP-Posting-Host: 24.74.175.102 Message-ID: <4173b404$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1098101764 24.74.175.102 (18 Oct 2004 05:16:04 -0700) X-Authenticated-User: edmulroy Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail