473,395 Members | 1,541 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

SendMessage without waiting or PostMessage with Data

84
Hi Guys,
I need to send a string from c# application to another c# Application.

On receiving application side the code i have is below.

Expand|Select|Wrap|Line Numbers
  1.  
  2.  protected override void WndProc(ref Message m)
  3.         {
  4.             switch (m.Msg)
  5.             {
  6.                 case (int)Msg.WM_USER:
  7.                     break;
  8.                 case (int)Msg.WM_COPYDATA:
  9.                     COPYDATASTRUCT mystr = new COPYDATASTRUCT();
  10.                     Type mytype = mystr.GetType();
  11.                     mystr = (COPYDATASTRUCT) m.GetLParam(mytype);
  12.                     //Here is where i want to do my processing but return the result
  13.                     //to calling application.
  14.                     break;
  15.             }
  16.  
  17.             base.WndProc(ref m);
  18.         }
  19.  
  20.  
  21.  

Ideally i dont want to wait after extracting mystr for results to be returned, i just want it to act like PostMessage. The reason i cant use PostMessage is because it doesnt work with WM_COPYDATA. Please help guys!!!!!!!!!!!!
Sep 16 '09 #1
2 5480
alag20
84
Okay guys!
After another day of messing around, i finally found the solution.

I am posting it here in case anyone else might need it as well.

You basically need to use ReplyMessage in Win32.dll in WndProc as shown below.

Expand|Select|Wrap|Line Numbers
  1.  
  2.  protected override void WndProc(ref Message m)
  3.         {
  4.             switch (m.Msg)
  5.             {
  6.                 case (int)Msg.WM_USER:
  7.                     break;
  8.                 case (int)Msg.WM_COPYDATA:
  9.                     COPYDATASTRUCT mystr = new COPYDATASTRUCT();
  10.                     Type mytype = mystr.GetType();
  11.                     mystr = (COPYDATASTRUCT) m.GetLParam(mytype);
  12.                     if (Win32.InSendMessage())
  13.                         Win32.ReplyMessage(IntPtr.Zero); //Returns 0 to calling application
  14.                     //Do your stuff here
  15.                     break;
  16.             }
  17.  
  18.             base.WndProc(ref m);
  19.         }
  20.  
  21.  
  22.  
Sep 17 '09 #2
GaryTexmo
1,501 Expert 1GB
I have no idea about any of this, I just wanted to say thanks for updating with your solution. This site seems to get a lot of google hits, so having this here is bound to help someone :)
Sep 17 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: nnb295 | last post by:
Hi, is it with the .Net-Class-library possible to send a message with the same effect like the API-Call "SendMessage" to another application window or control without Windows-API-Calls. ...
5
by: Johnsy Joseph | last post by:
Hello Everybody, I am trying to write a program that reads a single character, but I always need to press the enter key too. Is there any way to read just a single character without waiting for...
2
by: Jesper | last post by:
Hi, Is there a way to send a http message without waiting for the reply. I just want a server to register some information if its up and running. thanks Jesper.
3
by: JM | last post by:
Newbie Question Is there a way to use Message.Show so that it will allow the program to continue processing without waiting for a user to click OK?
7
by: gerry | last post by:
I have a com object that is used via an interop assembly - ie. I referenced the com object and vs.net created the interop .dll for it. I create one object per session when the page 1st loads and...
3
by: mista852003 | last post by:
Help?!!! How to delete the row in datagrid without delete from data source?
3
by: telduivel | last post by:
Can someone please help me with this: I have a python script, that at some point calls a linux bash script (.sh). Starting the shell script is the last thing my python script needs to do, so I...
8
by: Bill H | last post by:
In a php script I am using I need to call an external program and have it start running, but I don't want the php script to wait for it to finish. Looking at exec() and system() these would all...
9
by: erikcw | last post by:
Hi, I have a cgi script where users are uploading large files for processing. I want to launch a subprocess to process the file so the user doesn't have to wait for the page to load. What is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.