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

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

Reply via email to