Program.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System;
  2. using System.Windows.Forms;
  3. namespace ScreenSaverEf
  4. {
  5. //rundll32.exe desk.cpl,InstallScreenSaver %l
  6. internal static class Program
  7. {
  8. /// <summary>
  9. /// 应用程序的主入口点。
  10. /// </summary>
  11. [STAThread]
  12. private static void Main(string[] args)
  13. {
  14. Application.EnableVisualStyles();
  15. Application.SetCompatibleTextRenderingDefault(false);
  16. if (args.Length > 0)
  17. {
  18. if (args[0].Substring(0, 2).ToUpper().Equals("/C"))
  19. {
  20. MessageBox.Show("此屏幕保护没有可供设置的选项!", "Ef屏保",
  21. MessageBoxButtons.OK, MessageBoxIcon.Information);
  22. Application.Exit();
  23. }
  24. else if (args[0].ToUpper() == "/A")
  25. {
  26. MessageBox.Show("此屏幕保护没有可供设定口令的选项!", "Ef屏保",
  27. MessageBoxButtons.OK, MessageBoxIcon.Information);
  28. Application.Exit();
  29. }
  30. else if (args[0].ToUpper() == "/P")
  31. {
  32. var temp = args[1];//获取命令行中的屏保预览窗口句柄的字符串形式
  33. var CPWindow = (IntPtr)Convert.ToInt32(temp);
  34. new PreviewForm(CPWindow).ShowDialog();
  35. }
  36. else if (args[0].ToUpper() == "/S")
  37. {
  38. //正常启动
  39. for (var i = 1; i < Screen.AllScreens.Length; i++)
  40. {
  41. new MainForm(i).Show();
  42. }
  43. Application.Run(new MainForm());
  44. }
  45. }
  46. else
  47. {
  48. Application.Run(new MainForm());
  49. }
  50. }
  51. }
  52. }