Solved

Windows Service obtaining display device context using GetDC(NULL)

Posted on 2007-11-27
3
999 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 500 total points
ID: 20361903
Yes, an invisible, yet valid DC.
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Suggested Solutions

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
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…

733 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