?
Solved

Windows Service obtaining display device context using GetDC(NULL)

Posted on 2007-11-27
3
Medium Priority
?
1,043 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 total points
ID: 20361903
Yes, an invisible, yet valid DC.
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

771 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