using System.Runtime.InteropServices;
class UAPDBMQ0010 : Form
{
IntPtr tailHandle = IntPtr.Zero;
System.Timers.Timer tm = new System.Timers.Timer();
string qryText = "";
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr FindWindow(string strClassName, string strWindowName);
[DllImport("user32.dll")]
public static extern int SendMessage(int hWnd, uint Msg, int wParam, int lParam);
public UAPDBMQ0010(IntPtr prmHandle, string qryFileName)
{
tailHandle = prmHandle;
tm.Elapsed += new ElapsedEventHandler(____time_tick);
qryText = System.IO.File.ReadAllText(qryFileName);
}
void ____time_tick(object sender, ElapsedEventArgs e)
{
try
{
byte[] dataByte = Encoding.UTF8.GetBytes(qryText);
COPYDATASTRUCT copyData = new COPYDATASTRUCT();
copyData.dwData = (IntPtr)0;
copyData.cbData = dataByte.Length;
copyData.lpData = Marshal.AllocHGlobal(dataByte.Length);
Marshal.Copy(dataByte, 0, copyData.lpData, dataByte.Length);
IntPtr sendData = Marshal.AllocHGlobal(Marshal.SizeOf(copyData));
Marshal.StructureToPtr(copyData, sendData, true);
IntPtr _result = SendMessage(tailHandle, APMApiPublic.WM_COPYDATA, (IntPtr)index, sendData);
Marshal.FreeHGlobal(copyData.lpData);
Marshal.FreeHGlobal(sendData);
}
catch (Exception exp)
{
Console.WriteLine(exp.Message);
}
}
}
class APMCommManage : Form
{
IntPtr currentHandle = IntPtr.Zero;
public APMCommManage()
{
currentHandle = Handle;
}
protected override void WndProc(ref Message m)
{
const int WM_PAINT=0x000f;
base.WndProc(ref m);
switch(m.Msg)
{
case WM_PAINT:
break;
default:
break;
}
}
protected override bool ProcessCmdKey(ref Message m, Keys keyData)
{
const int WM_KEYDOWN=0x0100;
if(m.Msg==WM_KEYDOWN)
{
switch(keyData.ToString())
{
case "Return":
Console.WriteLine("HANDLE:" + "[" + currentHandle.ToString() + "]");
break;
case "Right":
break;
case "Left":
break;
case "Space":
DBMS2022FRM dbms2022frm = new DBMS2022FRM(currentHandle, "QUERY.567342.001");
dbms2022frm.Show();
break;
case "Escape":
Application.Exit();
break;
default:
break;
}
}
return base.ProcessCmdKey(ref m, keyData);
}
}
'c# 언어 > 중급과정' 카테고리의 다른 글
APMMusic.Down.Send.cs (0) | 2023.05.24 |
---|---|
MSI와 EXE의 차이점(1) (0) | 2023.03.07 |
public List<List<string>> data {get; set;} 활용예 (0) | 2022.11.16 |
JsonConvert.DeserializeObject, JsonConvert.SerializeObject (0) | 2022.11.16 |
WM_COPYDATA를 이용한 데이타 주고받기 (0) | 2022.11.09 |