G
gwhite1
I use this code to capture a screen in a regular VB 2005 windows app.
It works great! I found the code in google. But when I create a windows
service it does not capture the screen. It only captures a blank
graphic. Does anyone know why it will not capture the current screen?
Is something not available when running as a service? Thanks!!!
Sheila
Function CreateScreenshot() As System.Drawing.Bitmap
Dim Rect As System.Drawing.Rectangle =
System.Windows.Forms.Screen.PrimaryScreen.Bounds
Dim gDest As System.Drawing.Graphics
Dim hdcDest As IntPtr
Dim hdcSrc As Integer
CreateScreenshot = New System.Drawing.Bitmap(Rect.Right,
Rect.Bottom)
gDest = gDest.FromImage(CreateScreenshot)
hdcSrc = GetDC(0)
hdcDest = gDest.GetHdc
BitBlt(hdcDest.ToInt32, 0, 0, Rect.Right, Rect.Bottom, hdcSrc,
0, 0, SRCCOPY)
gDest.ReleaseHdc(hdcDest)
ReleaseDC(0, hdcSrc)
End Function
It works great! I found the code in google. But when I create a windows
service it does not capture the screen. It only captures a blank
graphic. Does anyone know why it will not capture the current screen?
Is something not available when running as a service? Thanks!!!
Sheila
Function CreateScreenshot() As System.Drawing.Bitmap
Dim Rect As System.Drawing.Rectangle =
System.Windows.Forms.Screen.PrimaryScreen.Bounds
Dim gDest As System.Drawing.Graphics
Dim hdcDest As IntPtr
Dim hdcSrc As Integer
CreateScreenshot = New System.Drawing.Bitmap(Rect.Right,
Rect.Bottom)
gDest = gDest.FromImage(CreateScreenshot)
hdcSrc = GetDC(0)
hdcDest = gDest.GetHdc
BitBlt(hdcDest.ToInt32, 0, 0, Rect.Right, Rect.Bottom, hdcSrc,
0, 0, SRCCOPY)
gDest.ReleaseHdc(hdcDest)
ReleaseDC(0, hdcSrc)
End Function