using System;
using System.Windows.Forms;
using System.Text;
using System.Runtime.InteropServices;
namespace RecvPackage
{
public class Program : Form
{
public const int WM_COPYDATA=0x004A;
public struct COPYDATASTRUCT
{
public IntPtr dwData;
public int cbData;
public IntPtr lpData;
}
public Program()
{
//From FindWindow(), This Application is Detected!!
//From FindWindow(), This Application is Detected!! //The KeyWord is Below String,,,,,
this.Text = "RecvSendDataMonitoring";
}
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
try
{
switch(m.Msg)
{
case WM_COPYDATA :
COPYDATASTRUCT cds = (COPYDATASTRUCT)m.GetLParam(typeof(COPYDATASTRUCT));
byte[] recvData = new byte[cds.cbData];
Marshal.Copy(cds.lpData, recvData, 0, cds.cbData);
Console.WriteLine(Encoding.Default.GetString(recvData));
break;
}
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
}
public static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Program());
}
}//end of class
}//end of namespace
'c# 언어' 카테고리의 다른 글
Console.WriteLine(">" + string.Format("{0:D10}", Convert.ToInt64(str))); (0) | 2022.01.03 |
---|---|
this.Text = "베트남어: Ti?ng Thai"; (0) | 2021.12.25 |
IntPtr _result = SendMessage(tailHandle, WM_COPYDATA, (IntPtr)index, sendData); (0) | 2021.12.25 |
From BackgroundWorker 매카니즘 (0) | 2021.12.24 |
From Process To Process, Message Send,Recv (0) | 2021.12.24 |