Solved

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

Posted on 2006-06-22
2
203 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 500 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Unix / Linux grid computing 5 127
Add content to output file 4 58
Tab names are off by one 5 49
wordcount challenge 11 78
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
This video discusses moving either the default database or any database to a new volume.

762 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now