Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
StretchBlt fails with error 5 (access denied)
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Derek  
View profile  
 More options Dec 19 2008, 2:00 pm
Newsgroups: comp.os.ms-windows.programmer.graphics
From: Derek <derekr...@gmail.com>
Date: Fri, 19 Dec 2008 11:00:35 -0800 (PST)
Local: Fri, Dec 19 2008 2:00 pm
Subject: StretchBlt fails with error 5 (access denied)
I have a simple console application program that captures a screenshot
of the display device and then saves the image to file as a bitmap.
The screenshot is generated successfully when run with my
(administrative) account, but when run under the local system account
it fails. Specifically, the StretchBlt( ) function fails and last
error is set to 5 (access denied).

The sequence of Windows API calls is as follows:

          HDC sourceDC =
          CreateDC( L"DISPLAY",        // lpszDriver - driver name
                          NULL,                  // lpszDevice -
device name
                          NULL,                  // lpszOutput - not
used; should be NULL
                          NULL );

          HDC memoryDC =
          CreateCompatibleDC( sourceDC );

          HBITMAP bitmap =
          CreateCompatibleBitmap( sourceDC,                    //
hdc     - handle to DC

horizontalResolution,    // nWidth  - width of bitmap, in pixels
                                                 verticalResolution );

          SelectObject( memoryDC, // hdc     - handle to DC
                               bitmap );

          StretchBlt( memoryDC,                          //
hdcDest      - handle to destination DC

0,                                        // nXOriginDest - x-coord of
destination upper-left corner

0,                                        // nYOriginDest - y-coord of
destination upper-left corner
                           horizontalResolution,            //
nWidthDest   - width of destination rectangle
                           verticalResolution,                //
nHeightDest  - height of destination rectangle
                           sourceDC,                            //
hdcSrc       - handle to source DC

0,                                        // nXOriginSrc  - x-coord of
source upper-left corner

0,                                        // nYOriginSrc  - y-coord of
source upper-left corner
                           sourceHorizonalResolution,    //
nWidthSrc    - width of source rectangle
                           sourceVerticalResolution,      //
nHeightSrc   - height of source rectangle
                           SRCCOPY );

(Note: For clarity, I have omitted error checking code from the above
excerpt. I am evaluating and handling the return value of every
function.).

All operations up until the StretchBlt function succeed.

Anyone know of any reason why this would fail when run under the
system account? I have reproduced this on several systems including XP
Pro and Vista.

Thanks for your help.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google