Không cho phép chụp hình ứng dụng bằng nút PrintScreen trên Winform C#
Để thực hiện bài viết này chúng ta chỉ cần sử dụng đoạn code call dll c# đơn giản như bên dưới:
C#:
using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsFormsAppPrtScrProtector
{
public partial class Form1 : Form
{
const uint WDA_NONE = 0;
const uint WDA_MONITOR = 1;
[DllImport("user32.dll")]
public static extern uint SetWindowDisplayAffinity(IntPtr hWnd, uint dwAffinity);
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
SetWindowDisplayAffinity(this.Handle, WDA_NONE);
}
}
}
Chúc các bạn thành công!