Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2006-06-22
2
Medium Priority
?
211 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
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Screencast - Getting to Know the Pipeline
Suggested Courses

972 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