Creo que el problema es que no liberas los recursos del objeto graphics ni del objeto Bitmap. La forma de hacer esto es llamar al método Dispose al terminar con ellos o usar using.
Con Using:
Código VB:
Ver originalPrivate Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If IsWindowVisible(GetForegroundWindow()) And statuswindow = False Then
Dim rct As RECT
Dim victima As Long = GetForegroundWindow()
GetWindowRect(GetForegroundWindow(), rct)
Using bmpScreenshot As New Bitmap(rct.Right - rct.Left, rct.Bottom - rct.Top, PixelFormat.Format24bppRgb)
Using gfxScreenshot As Graphics.FromImage(bmpScreenshot)
gfxScreenshot.CopyFromScreen(rct.Left, rct.Top, 0, 0, New Size(rct.Right - rct.Left, rct.Bottom - rct.Top), CopyPixelOperation.SourceCopy)
Try
bmpScreenshot.Save(sTempFolderPath & victima & ".png")
Catch ex As Exception
End Try
End Using
End Using
End If
End Sub
Sin Using:
Código VB:
Ver originalPrivate Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If IsWindowVisible(GetForegroundWindow()) And statuswindow = False Then
Dim rct As RECT
Dim victima As Long = GetForegroundWindow()
GetWindowRect(GetForegroundWindow(), rct)
Dim bmpScreenshot As Bitmap = New Bitmap(rct.Right - rct.Left, rct.Bottom - rct.Top, PixelFormat.Format24bppRgb)
Dim gfxScreenshot As Graphics = Graphics.FromImage(bmpScreenshot)
gfxScreenshot.CopyFromScreen(rct.Left, rct.Top, 0, 0, New Size(rct.Right - rct.Left, rct.Bottom - rct.Top), CopyPixelOperation.SourceCopy)
Try
bmpScreenshot.Save(sTempFolderPath & victima & ".png")
Catch ex As Exception
End Try
gfxScreenshot.Dispose();
bmpScreenshot.Dispose();
End If
End Sub