728x90
반응형
728x170
▶ MainForm.cs
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace TestProject
{
/// <summary>
/// 메인 폼
/// </summary>
public partial class MainForm : Form
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Import
////////////////////////////////////////////////////////////////////////////////////////// Static
//////////////////////////////////////////////////////////////////////////////// Private
#region 윈도우 디스플레이 어피너티 설정하기 - SetWindowDisplayAffinity(windowHandle, affinity)
/// <summary>
/// 윈도우 디스플레이 어피너티 설정하기
/// </summary>
/// <param name="windowHandle">윈도우 핸들</param>
/// <param name="affinity">어피너티</param>
/// <returns>처리 결과</returns>
[DllImport("user32")]
private static extern uint SetWindowDisplayAffinity(IntPtr windowHandle, uint affinity);
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Field
////////////////////////////////////////////////////////////////////////////////////////// Private
#region Field
/// <summary>
/// WDA_NONE
/// </summary>
private const uint WDA_NONE = 0;
/// <summary>
/// WDA_MONITOR
/// </summary>
private const uint WDA_MONITOR = 1;
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MainForm()
/// <summary>
/// 생성자
/// </summary>
public MainForm()
{
InitializeComponent();
this.preventButton.Click += preventButton_Click;
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Private
#region 캡처 방지 설정하기 버튼 클릭시 처리하기 - preventButton_Click(sender, e)
/// <summary>
/// 캡처 방지 설정하기 버튼 클릭시 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void preventButton_Click(object sender, EventArgs e)
{
if(this.preventButton.Text == "캡처 방지 설정하기")
{
SetWindowDisplayAffinity(this.Handle, WDA_MONITOR);
this.preventButton.Text = "캡처 방지 해제하기";
}
else
{
SetWindowDisplayAffinity(this.Handle, WDA_NONE);
this.preventButton.Text = "캡처 방지 설정하기";
}
}
#endregion
}
}
728x90
반응형
그리드형(광고전용)
'C# > WIN32' 카테고리의 다른 글
[C#/WIN32] LoadLibrary API 함수 선언하기 (0) | 2020.12.25 |
---|---|
[C#/WIN32] CreateRemoteThread API 함수 선언하기 (0) | 2020.12.23 |
[C#/WIN32] WriteProcessMemory API 함수 선언하기 (0) | 2020.12.23 |
[C#/WIN32] VirtualAllocEx API 함수 선언하기 (0) | 2020.12.23 |
[C#/WIN32] GetModuleHandle API 함수 선언하기 (0) | 2020.12.23 |
[C#/WIN32] OpenProcess API 함수 선언하기 (0) | 2020.12.23 |
[C#/WIN32] GetLastError API 함수 선언하기 (0) | 2020.12.23 |
[C#/WIN32] EnableMenuItem API 함수 : Close 버튼 비활성화하기 (0) | 2020.06.04 |
[C#/WIN32/.NET6] SendARP API 함수 : MAC 주소 구하기 (0) | 2019.08.16 |
[C#/WIN32] ExitWindowsEx API 함수 : 윈도우즈 종료하기/재부팅하기/로그오프하기 (0) | 2017.02.28 |
댓글을 달아 주세요