Jump to content
  • Advertisement
Sign in to follow this  
fathom88

Catch Dialog Win at Login Screen

This topic is 5415 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm trying to use Visual C++ to create a service that logs Windows Dialog Messages. The service works great when someone is logged on to the system. However, it will not work at the login screen. Hence, a Win warning message window won't be caught if it appears at the login screen. My original method uses FindWindow and GetText to work. However, it only works when a desktop is available. I recently found that no desktop exists at login screen. Any ideas around this? Can I catch an assert message generated by another app??

Share this post


Link to post
Share on other sites
Advertisement
As far as I know, theres no way around this. At the login screen, theres no user logged in, and the system is in a different state. I wasn't aware that FindWindow() needed a dekstop however...

What do you need to read dialogs at the login screen for anyway?

Share this post


Link to post
Share on other sites
The problem comes from another app. The Window generates a warning message when the app dumps (like on a divide by zero). The app was ment to restart itself but will not because the Windows does not allow the app to exit out until the dialog message is acknowledged by clicking OK. The app does not generate the dialog itself on purpose, but windows detects a problem inside it and brings it down. I thought about detecting the problem inside the app itself but it's in an unstable state when the error happens. Besides, there could be more problems which forces windows to create a dialog message. I want the app to be constantly running. If an error internally causes a Window dialog, I want the app to make a note of it and restart itself. The app is always running regardless of user login. Detecting it from a service seemed the easiest way.

Share this post


Link to post
Share on other sites
Here is an example of how to walk through existing window stations, desktops, and windows within those desktops.

Hope it helps.


#include <windows.h>

/* Enumerator Functions */
BOOL WINAPI WindowStationEnumerator(LPTSTR, LPARAM);
BOOL WINAPI DesktopEnumerator(LPTSTR, LPARAM);
BOOL WINAPI DesktopWindowEnumerator(HWND, LPARAM);


int
main(int argc, char *argv[])
{
EnumWindowStations(&WindowStationEnumerator, NULL);
}

BOOL WINAPI WindowStationEnumerator(LPTSTR lpszWindowStation, LPARAM lParam)
{
HWINSTA hStation;

hStation = OpenWindowStation(lpszWindowStation, 0, GENERIC_ALL);
if (hStation) {
EnumDesktops(hStation, &DesktopEnumerator, NULL);
CloseWindowStation(hStation);
return TRUE;
}
return TRUE;
}

BOOL WINAPI DesktopEnumerator(LPTSTR lpszDesktop, LPARAM lParam)
{
HDESK hDesktop;

hDesktop = OpenDesktop(lpszDesktop, 0, 0, GENERIC_ALL);
if (hDesktop) {
EnumDesktopWindows(hDesktop, &DesktopWindowEnumerator, NULL);
CloseDesktop(hDesktop);
return TRUE;
}
return TRUE;
}

BOOL WINAPI DesktopWindowEnumerator(HWND hWnd, LPARAM lParam)
{
// Do something interesting with windows found here!
return TRUE;
}



Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!