본문 바로가기

자료

[C#/VBNET] [API] 화면 캡쳐 방지 (Screen Capture Prevention)

728x90

[C#/VBNET] [API] 화면 캡쳐 방지 (Screen Capture Prevention)


전체 소스 코드

Form1.vb

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