CopyData.cs in WebService_WindowsMe


Exporting data read by windows messaging to another windows application via wind...Original Link
    Sponsored links

			
using System;
using System.Collections;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Windows.Forms;
using Manas;

namespace vbAccelerator.Components.Win32
{
	public delegate void DataReceivedEventHandler(object sender, DataReceivedEventArgs e);

	/// <summary>
	/// A class which wraps using Windows native WM_COPYDATA
	/// message to send interprocess data between applications.
	/// This is a simple technique for interprocess data sends
	/// using Windows.  The alternative to this is to use
	/// Remoting, which requires a network card and a way
	/// to register the Remoting name of an object so it
	/// can be read by other applications.
	/// </summary>
	public class CopyData : NativeWindow, IDisposable
	{	
		/// <summary>
		/// Event raised when data is received on any of the channels 
		/// this class is subscribed to.
		/// </summary>
		public event DataReceivedEventHandler DataReceived;

		[StructLayout(LayoutKind.Sequential)]
		private struct COPYDATASTRUCT
		{
			public IntPtr dwData;
			public int cbData;
			public IntPtr lpData;
		}
		
		private const int WM_COPYDATA = 0x4A;
		private const int WM_DESTROY = 0x2;

		#region Member Variables
		private CopyDataChannels channels = null;
		private bool disposed = false;
		#endregion

		/// <summary>
		/// Override for a form's Window Procedure to handle WM_COPYDATA
		/// messages sent by other instances of this class.
		/// </summary>
		/// <param name="m">The Windows Message information.</param>
		protected override void WndProc (ref System.Windows.Forms.Message m )
		{
			if (m.Msg == WM_COPYDATA)
			{
				COPYDATASTRUCT cds = new COPYDATASTRUCT();
				cds = (COPYDATASTRUCT) Marshal.PtrToStructure(m.LParam, typeof(COPYDATASTRUCT));
				if (cds.cbData > 0)
				{
					byte[] data = new byte[cds.cbData];		
					Marshal.Copy(cds.lpData, data, 0, cds.cbData);
					MemoryStream stream = new MemoryStream(data);
			

			...
			...
			... to be continued.

  This is a preview. To get the complete source file, 
  please click here to download the whole source code package.

			
			


Project Files

    Sponsored links
NameSizeDate
 01.00 B
 01.00 B
 Project1.cfg353.00 B02-08-08 12:57
 Project1.dof1.90 kB02-08-08 12:57
 Project1.dpr188.00 B02-08-08 12:57
 Project1.exe423.00 kB02-08-08 16:15
 Project1.res876.00 B02-08-08 12:56
 Unit1.dcu7.97 kB02-08-08 16:15
 Unit1.ddp51.00 B02-08-08 16:15
 Unit1.dfm1.01 kB02-08-08 16:11
 Unit1.pas3.60 kB02-08-08 16:15
 Unit1.~ddp51.00 B02-08-08 16:12
 Unit1.~dfm1.01 kB02-08-08 16:11
 Unit1.~pas3.70 kB02-08-08 16:12
 WebServiceInterface.exe128.00 kB02-08-08 16:05
 WebServiceInterface.exe.config894.00 B02-08-08 14:44
 WebServiceInterface.pdb309.50 kB02-08-08 16:05
 WebServiceInterface.vshost.exe5.50 kB09-23-05 07:56
 WebServiceInterface.vshost.exe.config894.00 B02-08-08 14:44
 01.00 B
 app.config894.00 B02-08-08 14:44
 01.00 B
 01.00 B
 WebServis2ElTerminali.exe168.00 kB02-08-08 12:44
 WebServis2ElTerminali.exe.config1.11 kB02-08-08 11:44
 WebServis2ElTerminali.pdb347.50 kB02-08-08 12:44
 WebServis2ElTerminali.vshost.exe.config943.00 B07-19-06 17:16
 CopyData.cs14.90 kB02-08-08 14:59
 DataClass1.cs1.12 kB06-08-06 17:12
 EnumWindows.cs13.01 kB06-08-06 17:08
 Frm_KPS.cs11.29 kB02-08-08 16:05
 Frm_KPS.Designer.cs3.65 kB02-08-08 14:58
 Frm_KPS.resx5.68 kB02-08-08 14:58
 01.00 B
 01.00 B
 012.00 B
 ResolveAssemblyReference.cache7.65 kB02-08-08 11:47
 01.00 B
 Properties.Resources.Designer.cs.dll5.50 kB02-08-08 14:21
 Web40.00 kB02-08-08 14:21
 Web108.00 kB02-08-08 14:29
 Web32.00 kB06-10-06 10:22
 WebServiceInterface.csproj.GenerateResource.Cache920.00 B02-08-08 14:59
 WebServiceInterface.exe128.00 kB02-08-08 16:05
 WebServiceInterface.Frm_KPS.resources180.00 B02-08-08 14:59
 WebServiceInterface.pdb309.50 kB02-08-08 16:05
 WebServiceInterface.Properties.Resources.resources180.00 B02-08-08 14:10
 WebServis2ElTerminali.csproj.GenerateResource.Cache920.00 B02-08-08 12:08
 WebServiceInterface.csproj.FileListAbsolute.txt1.64 kB02-08-08 16:05
 WebServis2ElTerminali.csproj.FileList.txt428.00 B10-30-06 16:41
 WebServis2ElTerminali.csproj.FileListAbsolute.txt1.19 kB02-08-08 13:20
 Program.cs488.00 B02-08-08 14:12
 01.00 B
 AssemblyInfo.cs1.26 kB02-08-08 14:33
 Resources.Designer.cs2.80 kB02-08-08 14:08
 Resources.resx5.48 kB06-10-06 10:19
 Settings.Designer.cs1.64 kB02-08-08 14:44
 Settings.settings507.00 B02-08-08 14:44
 Utilities.cs6.49 kB02-08-08 14:18
 <Web>0.00 B01-02-09 16:33
 <Web>0.00 B01-02-09 16:33
 Web637.00 B02-08-08 14:21
 Web651.00 B02-08-08 14:21
 Web629.00 B02-08-08 14:21
 Web631.00 B02-08-08 14:21
 Web647.00 B02-08-08 14:21
 Web629.00 B02-08-08 14:21
 Web651.00 B02-08-08 14:21
 Web631.00 B02-08-08 14:21
 Web635.00 B02-08-08 14:21
 Web637.00 B02-08-08 14:21
 Web639.00 B02-08-08 14:21
 Web645.00 B02-08-08 14:21
 Web663.00 B02-08-08 14:21
 Web637.00 B02-08-08 14:21
 Web639.00 B02-08-08 14:21
 Web745.00 B02-08-08 14:21
 Web104.22 kB02-08-08 14:21
 Web637.00 B02-08-08 14:21
 Web653.00 B02-08-08 14:21
 Web647.00 B02-08-08 14:21
 Web639.00 B02-08-08 14:21
 Web645.00 B02-08-08 14:21
 Web205.96 kB02-08-08 14:29
 Web588.00 B02-08-08 14:21
 Web651.00 B02-08-08 14:21
 WebServiceInterface.csproj7.66 kB02-08-08 14:44
 WebServiceInterface.idc634.00 B02-08-08 11:46
 WebServiceInterface.sln926.00 B02-08-08 14:29
 WebServiceInterface.suo36.50 kB02-08-08 15:56
...

Related Items

    Sponsored links