Solved

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

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Turn a spreadsheet into a vba executable. 2 103
fizzArray  challenge 1 115
scoreUp challenge 14 74
changeXy challenge 13 98
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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 shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.
Suggested Courses

739 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