Anyone know how to cripple GetDC to prevent screen capture? (like clevercontent.com )
Printable View
Anyone know how to cripple GetDC to prevent screen capture? (like clevercontent.com )
There is a pool of device contexts maintained by the OS.
If you repeatedly call GetDC until it fails, you have exhausted the pool. This basically locks up the graphics output on the system, except for CreateDC. This is not a good idea, because you have to restore them with ReleaseDC before you exit your code, and some windows will become blocked, which can cause permanent deadlocks because they have a mutex on a resource your code needs - non-DC resource.
This is one way to 'disable' the PrintScreen key. Run a DoEvents loop and check the state if the Print Screen key, if it is pressed then Clear the clipboard object.
Code:
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Const VK_PRNTSCRN = &H2C
Private Sub Form_Load()
Me.Show
Do Until DoEvents = 0
' if print screen button pressed
If GetAsyncKeyState(VK_PRNTSCRN) Then
Clipboard.Clear
End If
Loop
End Sub
any idea how big the pool is? My attempts seem to just slow down the system without exhaustiung the pool.Quote:
Originally posted by jim mcnamara
There is a pool of device contexts maintained by the OS.
If you repeatedly call GetDC until it fails, you have exhausted the pool. This basically locks up the graphics output on the system, except for CreateDC.
The clipboard clearing is not general enough I'm afraid (doesn't stop things like PSP)Quote:
Originally posted by jim mcnamara
Youngbuck
Jim;PiltQuote:
Originally posted by jim mcnamara
There is a pool of device contexts maintained by the OS.
If you repeatedly call GetDC until it fails, you have exhausted the pool. This basically locks up the graphics output on the system, except for CreateDC. This is not a good idea, because you have to restore them with ReleaseDC before you exit your code, and some windows will become blocked, which can cause permanent deadlocks because they have a mutex on a resource your code needs - non-DC resource.
After painting with a common DC, the ReleaseDC function must be called to release the DC. Class and private DCs do not have to be released. ReleaseDC must be called from the same thread that called GetDC. The number of DCs is limited only by available memory.
Windows 95/98/Me: There are only 5 common DCs available per thread, thus failure to release a DC can prevent other applications from accessing one.
I bet your trying to create a cheat that dissallows punkbuster from taking screenshots during your gameplay? :p