Do you have "Allow service to interact with desktop" checked in the service 
properties?  Are the results consistent if you toggle the checkbox and restart the 
service? 

FYI: 

INFO: Services, Desktops, and Window Stations
http://support.microsoft.com/default.aspx?scid=kb;en-us;171890  

INFO: Security, Services and the Interactive Desktop
http://support.microsoft.com/default.aspx?scid=kb;EN-US;327618


Peter Guzis
Web Administrator, Sr.
ENCAD, Inc.
- A Kodak Company
email: [EMAIL PROTECTED]
www.encad.com 

-----Original Message-----
From: Roy Huggins [mailto:[EMAIL PROTECTED]
Sent: Tuesday, April 27, 2004 6:16 PM
To: Peter Guzis
Cc: [EMAIL PROTECTED]
Subject: Re: Screen Capture Desktop as Service


The service does seem to have a desktop. I know this because:

a) At least one guru has told me so. :)
b) When I invoke GetThreadDesktop() from my service, I get a valid return
value of 964 (when I invoke the script from my desktop rather than as a
service, I get a return value of 64.)
c) When I launch an app (Internet Explorer) that has a window from my
service, and I pass that window's handler to Win32::Screenshot as the item
to get a screencap of, the captured image I get is an area of my desktop
with the same dimensions as that window and in the same location I would
expect it to be in (based on where it appears when I run this script on my
desktop rather than as a service.) My tests indicate that the IE window
launches successfully and I can use the Navigate() method to load a web page
in it.

So it does seem to have a desktop. I would welcome anyone pointing out any
flaws in my logic here.

In response to Peter, I would like to be able to get screen captures of
program windows in an automated manner and I'd prefer that it be able to
happen in the background. :)

-Roy

----- Original Message ----- 
From: "Peter Guzis" <[EMAIL PROTECTED]>
To: "Roy Huggins" <[EMAIL PROTECTED]>;
<[EMAIL PROTECTED]>
Sent: Tuesday, April 27, 2004 5:45 PM
Subject: RE: Screen Capture Desktop as Service


> AFAIK, services running in the LocalSystem context have no desktop of
which to speak.  Creating an interactive environment (desktop) for something
explicitly defined as non-interactive (service) would serve no purpose.
>
> Assuming there was a system desktop, what were you hoping to capture?
>
> Peter Guzis
> Web Administrator, Sr.
> ENCAD, Inc.
> - A Kodak Company
> email: [EMAIL PROTECTED]
> www.encad.com
>
> -----Original Message-----
> From: Roy Huggins [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, April 27, 2004 5:28 PM
> To: [EMAIL PROTECTED]
> Subject: Screen Capture Desktop as Service
>
>
> Hola.
>
> After Randy Kobes very kindly helped me get a working copy of
> Win32::Screenshot, I have been testing using it in a script running as a
> service. It is pretty essential that I be able to run this app as a
service.
>
> The difficulty is that Win32::Screenshot always seems to grab it's shot
from
> the logged-in user's desktop, not from the service's desktop. There is one
> XS function that performs all the heavy lifting, whcih I have included the
> text of at the end of this message.
>
> Does anyone know of any way that I can create an environment in which
> Win32::Screenshot will regard the service's desktop as the location to
> retrieve it's image from rather than the logged-in user's desktop?
>
> Can anyone shoot me down if they know for sure that one cannot get a
> graphical image of a desktop that is owned by a service?
>
> Thanks very much!
> -Roy Huggins
>
> XS function CaptureHwndRect(), which does the actual capturing for
> Screenshot.pm:
> ========================================
> XS(XS_Win32__Screenshot_CaptureHwndRect); /* prototype to
> pass -Wmissing-prototypes */
> XS(XS_Win32__Screenshot_CaptureHwndRect)
> {
>     dXSARGS;
>     if (items != 5)
>  Perl_croak(aTHX_ "Usage: Win32::Screenshot::CaptureHwndRect(handle, xx,
yy,
> ww, hh)");
>     SP -= items;
>     {
>  HWND handle = (HWND)SvIV(ST(0));
>  LONG xx = (LONG)SvIV(ST(1));
>  LONG yy = (LONG)SvIV(ST(2));
>  LONG ww = (LONG)SvIV(ST(3));
>  LONG hh = (LONG)SvIV(ST(4));
> #line 292 "Screenshot.xs"
>     HDC  hdc;
>     HDC  my_hdc;
>     HBITMAP my_hbmp;
>     BITMAPINFO  my_binfo;
>     long bufferlen;
>     LPVOID buffer;
>     int  out;
>     long i;
>     long *p;
> #line 587 "Screenshot.c"
> #line 303 "Screenshot.xs"
>     hdc = GetDC(handle);
>
>     /* create in-memory bitmap for storing the copy of the screen */
>     my_hdc  = CreateCompatibleDC(hdc);
>     my_hbmp = CreateCompatibleBitmap(hdc, ww, hh);
>     SelectObject(my_hdc, my_hbmp);
>
>     /* copy the part of screen to our in-memory place */
>     BitBlt(my_hdc, 0, 0, ww, hh, hdc, xx, yy, SRCCOPY);
>
>     /* now get a 32bit device independent bitmap */
>     ZeroMemory(&my_binfo, sizeof(BITMAPINFO));
>
>     /* prepare a buffer to hold the screen data */
>     bufferlen = hh * ww * 4;
>     buffer = (LPVOID) safemalloc(bufferlen);
>
>     /* prepare directions for GetDIBits */
>     my_binfo.bmiHeader.biSize       = sizeof(BITMAPINFOHEADER);
>     my_binfo.bmiHeader.biWidth       = ww;
>     my_binfo.bmiHeader.biHeight      = -hh; /* negative because we want
> top-down bitmap */
>     my_binfo.bmiHeader.biPlanes      = 1;
>     my_binfo.bmiHeader.biBitCount    = 32; /* we want RGBQUAD data */
>     my_binfo.bmiHeader.biCompression = BI_RGB;
>
>     if(GetDIBits(my_hdc, my_hbmp, 0, hh, buffer, &my_binfo,
DIB_RGB_COLORS))
> {
>
>         /* Convert RGBQUADs to format expected by Image::Magick .rgba file
> (BGRX -> RGBX) */
>         p = buffer;
>         for( i = 0 ; i < bufferlen/4 ; i++  ) {
>           *p = ((*p & 0x000000ff) << 16) | ((*p & 0x00ff0000) >> 16) | (*p
&
> 0x0000ff00) | 0xff000000;
>           p++;
>         }
>
>         EXTEND(SP, 3);
>         PUSHs(sv_2mortal(newSViv(my_binfo.bmiHeader.biWidth)));
>         PUSHs(sv_2mortal(newSViv(abs(my_binfo.bmiHeader.biHeight))));
>         PUSHs(sv_2mortal(newSVpvn((char*) buffer, bufferlen)));
>         out = 1;
>     } else {
>       out = 0;
>     }
>
>     safefree(buffer);
>     DeleteDC(my_hdc);
>     ReleaseDC(handle, hdc);
>     DeleteObject(my_hbmp);
>
>     if ( out == 1 ) { XSRETURN(3); } else { XSRETURN_NO; }
> #line 638 "Screenshot.c"
>  PUTBACK;
>  return;
>     }
> }
>
>
> ---
> Outgoing mail has been scanned for viruses by AVG.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.668 / Virus Database: 430 - Release Date: 4/25/2004
>
> _______________________________________________
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>


---
Outgoing mail has been scanned for viruses by AVG.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.668 / Virus Database: 430 - Release Date: 4/25/2004


_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to