• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 7786
  • Last Modified:

C# SendMessage string with WM_COPYDATA

I need a code example of a working SendMessage api call in C# which sends a string, and also a WndProc example of how it is received and turned into a string again. Im tired of fighting this. Also, how to send a simple integer would also be a plus..
0
c03dn
Asked:
c03dn
  • 4
  • 2
1 Solution
 
rsripracCommented:
Hello,

Have you seen this post?

http://www.dotnet247.com/247reference/msgs/43/217002.aspx

They suggest to pass strings via WM_COPYDATA and not use SendMessage for string.  Heres to decoding:

http://www.dotnet247.com/247reference/msgs/7/35565.aspx

-Ram
0
 
c03dnAuthor Commented:
WM_COPYDATA would be used in with SendMessage, as it would have been the actual message code. None of the sites really made me wiser, I need a code example.. both send and receive.
0
 
rsripracCommented:
How about the source from here:

http://www.codeproject.com/threads/ipc_wmcopy.asp

-Ram
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
c03dnAuthor Commented:
That's c++.. for one, it's using CSTRING. I need a full c# sample with the dll imports and all.
0
 
c03dnAuthor Commented:
I can't even send a simple integer. Even though my lparam parameter in SendMessage is int, the message received has an IntPtr. How do I get the integer value? .toInt32() doesn't give me the right value. I am guessing it is a pointer to a memory adress, and how do I work with that? Do I need to use unsafe?
0
 
c03dnAuthor Commented:
0
 
GhostModCommented:
PAQed, with points refunded (250)

GhostMod
Community Support Moderator
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now