|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Any 'Windows Service' Experts? Why can't I capture the screen??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 gwhi***@kc.rr.com wrote:
Show quoteHide quote > I use this code to capture a screen in a regular VB 2005 windows app. The windows service runs in it's own session. This is why you can't > 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 > make an interactive service and you can't screen capture. Chris On 24 Apr 2006 18:43:47 -0700, gwhi***@kc.rr.com wrote:
Show quoteHide quote >I use this code to capture a screen in a regular VB 2005 windows app. I'm not sure if this is related, but:>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 With Windows Media Player ver 9 and earlier, you use to be able to screen capture a running video via the PrintScreen key and the frame that was playing at the time would show in the resulting capture. With ver 10 (and possibly from an additional XP upgrade), you no longer can capture the frame. All you get is a blank media player. Screen capture of a running video on any other player that I have, here, works as expected. I don't recall what MS calls it, but I believe it has something to do with their attempt to protect media licensing rights. Gene GWhite,
A service cannot reach (direct) the screen. (I never tried it, therefore it was to often written here). Cor <gwhi***@kc.rr.com> schreef in bericht Show quoteHide quote news:1145929427.640052.51450@v46g2000cwv.googlegroups.com... >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 > Try perhaps to check the "allow service to interact with desktop" checkbox.
A service is generally not tied to the desktop. It runs in its own context... -- Show quoteHide quotePatrice <gwhi***@kc.rr.com> a écrit dans le message de news: 1145929427.640052.51***@v46g2000cwv.googlegroups.com... >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 >
Interesting Results In VB.Net
Shared dll paths Accessing Foxpro Database VB.NET reading CSV files (odbc or oledb) vb.net 2005 - how to populate a listbox Register DLL for COM interop Performance testing tools for VB.NET application i need Code Generator... COM reference (X) as Interop.X Sql query..... Sum of another aggragate function |
|||||||||||||||||||||||