MainClass.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System;
  2. using System.Runtime.InteropServices;
  3. using System.Threading;
  4. using System.Windows.Forms;
  5. using Client.Start;
  6. namespace Client
  7. {
  8. public class MainClass
  9. {
  10. public static void Main()
  11. {
  12. try
  13. {
  14. //Client后台运行
  15. //new MainClass();
  16. ServiceMBIClientHandler.Start();
  17. }
  18. catch (Exception ex)
  19. {
  20. Console.WriteLine(ex.Message);
  21. }
  22. while (true)
  23. Console.ReadKey();
  24. }
  25. [DllImport("User32.dll", EntryPoint = "FindWindow")]
  26. private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
  27. [DllImport("user32.dll", EntryPoint = "FindWindowEx")] //找子窗体
  28. private static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
  29. [DllImport("User32.dll", EntryPoint = "SendMessage")] //用于发送信息给窗体
  30. private static extern int SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, string lParam);
  31. [DllImport("User32.dll", EntryPoint = "ShowWindow")] //
  32. private static extern bool ShowWindow(IntPtr hWnd, int type);
  33. public MainClass()
  34. {
  35. Console.Title = "MyConsoleApp";
  36. IntPtr ParenthWnd = new IntPtr(0);
  37. IntPtr et = new IntPtr(0);
  38. ParenthWnd = FindWindow(null, "MyConsoleApp");
  39. ShowWindow(ParenthWnd, 1);//隐藏本dos窗体, 0: 后台执行;1:正常启动;2:最小化到任务栏;3:最大化
  40. }
  41. }
  42. }