Article View: borland.public.csharpbuilder.language.csharp
Article #117Re: WM_COPYDATA
From: Marc Rohloff TeamB
Date: Sat, 20 Jan 2007 19:31
Date: Sat, 20 Jan 2007 19:31
40 lines
2339 bytes
2339 bytes
On Sat, 20 Jan 2007 17:28:43 -0000, Ray wrote:
> Hi
>
> I am trying to use WM_COPYDATA to send data between applications. I can send
> one integer successfully but if I try to send more than one the second is
> garbage.
> cds.cbData = Marshal.SizeOf(cds.dwData);
This should be
cds.cbData = Marshal.SizeOf(sendData);
A simpler way to call SendMessage would be:
public class Win32
{
[DllImport("user32.dll", CharSet=CharSet.Ansi)]
public static extern int SendMessage(
HandleRef hWnd,
int msg,
IntPtr wParam,
[In, Out,
MarshalAs(UnmanagedType.LPStruct)]
CopyDataStruct lParam);
[StructLayout(LayoutKind.Sequential, Pack=4)]
public struct CopyDataStruct
{
public int dwData;
public int cbData;
public IntPtr data;
}
This way you can just pass a CopyDataStruct into SendMessage without
having to worry about Marshalling it.
--
Marc Rohloff [TeamB]
marc rohloff -at- myrealbox -dot- com
Technical Details
Message-ID:
<80n5rkq4zz6p.dlg@dlg.marcrohloff.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<45b250bd@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 1efe35,5bed5c3cf1c76c51 X-Google-Attributes: gid1efe35,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Marc Rohloff [TeamB]" <"on request"> Subject: Re: WM_COPYDATA Newsgroups: borland.public.csharpbuilder.language.csharp User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit References: <45b250bd@newsgroups.borland.com> Date: Sat, 20 Jan 2007 14:31:16 -0500 Message-ID: <80n5rkq4zz6p.dlg@dlg.marcrohloff.com> X-Face: "huzh55Xi]!ZNni78>a*5+).`SK?<^q2MlHk-C]Z2M9T@\J5ZCB$95Ey+s"XQuhGFA[eutZ :0^AV!Q;t>gE`1-=8d;HZ6~*o1dH<X9\b$!|(}+I'!Xq)@3Op}%0ArW&nf'Qh*EwR X-Antivirus: avast! (VPS 0704-0, 01/18/2007), Outbound message X-Antivirus-Status: Clean NNTP-Posting-Host: 65.31.1.121 X-Trace: newsgroups.borland.com 1169321444 65.31.1.121 (20 Jan 2007 11:30:44 -0800) Lines: 40 X-Authenticated-User: mrohloff Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail