Solved

Windows Service obtaining display device context using GetDC(NULL)

Posted on 2007-11-27
3
992 Views
Last Modified: 2013-12-03
Hi Experts,

I am writing a windows service running on Windows Server 2003. The service performs some printing operations by obtaining a printer DC and a display DC. I'm wondering if there should be any issue for the service (running as SYSTEM user) to call GetDC(NULL) or if there is any reason to be concerend about this call? Will it return NULL or have any problems associated with the display HDC returned?

Thanks for your time,
Brandon
0
Comment
Question by:bdunz19
  • 2
3 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 20361595
If you don't actually have to display any visible results on the screen, you should be fine LocalSystem runs on a different desktop than the logged-in user, so you'd have to circumvent that issue.
0
 
LVL 4

Author Comment

by:bdunz19
ID: 20361818
Right nothing is being displayed on the screen. The purpose of the Display DC is to obtain logical pixels X-Y or font sizes from the current display, ect.

So based on your response I should conclude that the service will recieve a valid DC which functions that perform actions on that DC (like described above) will all complete successfully?

Thanks jkr,
Brandon
0
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 20361903
Yes, an invisible, yet valid DC.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question