본문 바로가기

자료

[VB.net/C# 화면 캡쳐 방지 API 함수(SetWindowDisplayAffinity)

728x90

[VB.net/C# 화면 캡쳐 방지 API 함수(SetWindowDisplayAffinity)


 

Imports System.Runtime.InteropServices

Public Class Form1

    <DllImport("user32.dll")> Private Shared Function SetWindowDisplayAffinity(ByVal hWnd As IntPtr, _
                                                                               ByVal dwAffinity As UInteger) As <MarshalAs(UnmanagedType.Bool)> Boolean
    End Function

    Private Const ui_NONE As UInteger = &H0
    Private Const ui_SET As UInteger = &H1

    Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click

        If button1.Text = "캡처 방지 설정하기" Then

            SetWindowDisplayAffinity(Me.Handle, ui_SET)
            button1.Text = "캡처 방지 해제하기"

        Else

            SetWindowDisplayAffinity(Me.Handle, ui_NONE)
            button1.Text = "캡처 방지 설정하기"

        End If

    End Sub
End Class
728x90