Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

When "Lock Computer" is selected, Rendering device not found

Posted on 2006-06-22
2
Medium Priority
?
209 Views
Last Modified: 2013-11-20
I'm having trouble detecting when a computer is sent into locked mode.  

The problem is that if my application is maximized, the 3D module gives the error "Render Error: Cannot get a D3D device for rendering" as soon as the computer enters locked mode.  In most cases the app ends up having to be killed by the task manager.

I need to be able to detect when the computer is locked or when the rendering device is not available so that I can suspend drawing until the user loggs back in.
0
Comment
Question by:bigsteve87
[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 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 2000 total points
ID: 16963681
That in fact is quite simple if you use a Winlogon Notification Package, see http://msdn.microsoft.com/library/en-us/secauthn/security/winlogon_notification_packages.asp ("Winlogon Notification Packages"), all you need to do is to create a DLL that contains

// Here is the event handler for the Winlogon Lock event.
VOID WLEventLockComputer (PWLX_NOTIFICATION_INFO pInfo)
{

    // Print the name of the handler to debug output.
    // You can replace this with more useful functionality.
    OutputDebugString (TEXT("NOTIFY:  Entering WLEventLockComputer.\r\n"));
}

// Here is the event handler for the Winlogon Unlock event.
VOID WLEventUnlockComputer (PWLX_NOTIFICATION_INFO pInfo)
{

    // Print the name of the handler to debug output.
    // You can replace this with more useful functionality.
    OutputDebugString (TEXT("NOTIFY:  Entering WLEventLogff.\r\n"));
}

and register these two functions in the Registry under

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\Notify\MyLockUnlockHandler

as described in http://msdn.microsoft.com/library/en-us/secauthn/security/registry_entries.asp ("Registry Entries")

Your handlers can just e.g. set an event so that your app can stop rendering and start it later on again.
0
 

Author Comment

by:bigsteve87
ID: 16964851
Thanks jkr

That is exactly what I was looking for, but this bug doesn't really justify the time it will take to create and add a new DLL to the project / installation / patcher.

Since this only happens when the main window is maximized, I found a message sent by windows with Spy++ called WM_WINDOWPOSCHANGING when I lock the computer, the only difference between when the message is sent here and when it is sent normally is that here WINDOWPOS.x and y are set to -4.  That seems to work for now.
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…

688 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