我在 C# 中有以下控制台应用程序
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Timers;
using System.Windows.Forms;
namespace PreventScreenshot
{
class Program
{
[STAThread]
public static void Main(string[] args)
{
System.Timers.Timer timer1 = new System.Timers.Timer();
timer1.Elapsed += new ElapsedEventHandler(timer_Tick);
timer1.Interval = 1000;
timer1.Enabled = true;
timer1.Start();
Console.WriteLine("---Prevent Screenshot from being taken---");
Console.WriteLine();
Console.WriteLine("DLL operation started. Try to take a screenshot");
Console.WriteLine();
Console.WriteLine("Press enter to exit");
Console.ReadLine();
}
public static void timer_Tick(object sender, EventArgs e)
{
Clipboard.Clear();
}
}
}
假设应用程序每秒清除剪贴板。但是,它不起作用。问题是什么?
编辑:
我刚刚编辑了代码。当我尝试运行程序时,剪贴板仍未清除。怎么了?