Is it possible to perform a delayed shutdown of the computer using an API function that displays a "you are about to exit" message, similar to performing a shutdown /s /t xx /c "xxxxxxxx" when the shutdown is scheduled for less than a minute?
MSDN's documentation on InitiateSystemShutdown says so:
If dwTimeout is not zero, InitiateSystemShutdown displays a dialog
box on the specified computer. The dialog box displays the name of the
user who called the function, displays the message specified by the
lpMessage parameter, and prompts the user to log off. The dialog box
beeps when it is created and remains on top of other windows in the
system. The dialog box can be moved but not closed. A timer counts
down the remaining time before a forced shutdown.
It does not so much fit what I am looking for...
Related
When I debug my program, which consists of looping over thousands of entries in vectors multiple times, it simply freezes the program but does not provide any error messages whatsoever. Does Visual Studio have some sort of auto-time out that I am experiencing?
Check may be your program is going into infinite loop Or doing some heavy task that makes your UI unresponsive(if you have windows form). Since you are debugging this program then why dont you set breakpoint in code and check where your program is causing issue.
And yes there is no time out for Visual Studio,But for program window.This is known as Hang Status.
When an application (or more accurately, a thread) creates a window on the desktop, it enters into an implicit contract with the Desktop Window Manager (DWM) to process window messages in a timely fashion. The DWM posts messages (keyboard/mouse input and messages from other windows, as well as itself) into the thread-specific message queue. The thread retrieves and dispatches those messages via its message queue. If the thread does not service the queue by calling GetMessage(), messages are not processed, and the window hangs: it can neither redraw nor can it accept input from the user. The operating system detects this state by attaching a timer to pending messages in the message queue. If a message has not been retrieved within 5 seconds, the DWM declares the window to be hung. You can query this particular window state via the IsHungAppWindow() API.
Detection is only the first step. At this point, the user still cannot even terminate the application - clicking the X (Close) button would result in a WM_CLOSE message, which would be stuck in the message queue just like any other message. The Desktop Window Manager assists by seamlessly hiding and then replacing the hung window with a 'ghost' copy displaying a bitmap of the original window's previous client area (and adding "Not Responding" to the title bar). As long as the original window's thread does not retrieve messages, the DWM manages both windows simultaneously, but allows the user to interact only with the ghost copy. Using this ghost window, the user can only move, minimize, and - most importantly - close the unresponsive application, but not change its internal state.
A nice article is written in this following link.
How program window works
I have an MS Access form that checks for certain records in a form timer event.
When it finds records it prints a report to the default Windows printer.
The problem is the Windows print status/progress window pops up (You know, the one that goes Printing page x of (document name)). And it, of course, has a cancel button.
But that progress window is interfering with normal form operations. I want to print in the background (silent printing?) without showing that progress window.
Any way to do that in the printer settings or from vba or other?
No, that's by design.
But you could move this timer form and the report to another database and run this minimized - your current application could open this automatically when launched.
So I've been working on my personal Steam account swapper with pre-game choice options but, I've been running into a few problems. The program works fine but I'm getting this problem where when I chose which profile I want logon to (for smurfing purposes) the Steam window pops up in my face and it prevents me from being able to choose which game I want to play. So I was wondering if there's a way to close the Steam window (and only the window) as soon as it pops up. taskkilling it won't work because if you taskkill it right away it will close the login (login starts when I choose which account I want to play on)
TL;DR I want to close steam window as soon as it pops up
NOTE: When logging in, task manager reads the steam logon window as SteamLogin and not Steam Not sure if this would make the lightbulb go off.
In steam there is an option to suppress the login prompt on system boot, I am not 100% if this will work with your loginswitcher, but is worth a try.
Go to "start menu", "run", type "regedit".
In the registry editor, expand the tree until you find this HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
In "Run", you will find all applications that are starting with Windows. Edit the value for "Steam" and add the silent option (-silent).
Reboot and try your login switcher.
Under Win2K(or later), by sending a Virtual-Key VK_LAUNCH_MEDIA_SELECT, can start a player.
If more than one player software installed, how to determine which one it will start?
A sample VBS code:
Wscript.CreateObject("Wscript.Shell").Sendkeys chr(&h88b5)
http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
http://msdn.microsoft.com/zh-cn/library/dd375731
VK_LAUNCH_MEDIA_SELECT
0xB5
Select Media key
VK_LAUNCH_MEDIA_SELECT is actually received by the system and translated into a WM_APPCOMMAND with lParam as APPCOMMAND_LAUNCH_MEDIA_SELECT. So theoretically, any program implementing a handler for this could be launched. This page (albeit old) lists default applications which listen for WM_APPCOMMAND:
Internet Explorer
Windows Help
DVD Player
CD Player
Media Player
Volume Control system tray applet
Obviously, only a few of those are actually applicable for APPCOMMAND_LAUNCH_MEDIA_SELECT.
However, I don't know how the translation mechanism actually works. It appears not every application will receive the translated WM_APPCOMMAND message. On my keyboard, I tried pressing the button which sends VK_VOLUME_UP. The volume goes up as expected because it is handled by the volume control system tray applet. However, I opened an instance of notepad.exe and monitored its messages with Spy++. It did not receive any message even when it was in the foreground. Curiously, VK_MEDIA_PLAY_PAUSE is received through WM_APPCOMMAND if the play/pause button is pressed as long as notepad.exe had the focus. I would test with VK_LAUNCH_MEDIA_SELECT, but I'm not actually sure what button that corresponds to (or whether my keyboard has it).
Thanks, for Mike Kwan's reply.
Through testing a lot of settings a program associated with a variety of audio files.
Finalized, this will depend on the CDA (CD Audio) files associated with which program.
If you set the default association for the CDA (CD Audio) files to Notepad or Paint or any other program, it can still send the same virtual key to open the corresponding program.
The foreground window can do whatever it wants in response to the WM_APPCOMMAND message, if it does not handle the message then shell hooks (HSHELL_APPCOMMAND) gets to handle it, if no hooks handle the message then Windows checks the AppKey key in the registry. (You can use Process Monitor to find the number for a specific key-press)
When updates are available and the user selects Shut Down from the Windows start menu, a dialog appears with a menu for Shutdown, Log Off etc.
One option which appears is
"Install Updates And Shut Down"
The question is, what exactly happens when the user presses OK?
Is the task showing the dialog Explorer? (It seems impossible to tell with process monitor spying, because the desktop is frozen)
I assume (But am not sure) this is Explorer and when the user presses OK it calls ExitWindowsEx
If So the question is what is different when the user selects "Install Updates And Shut Down" would it send special flags to ExitWindowsEx or perhaps call another API and would there be any way to spy this functionality?
when the user clicks "ok", it logs out every connected user then it installs all pending updates. the update installation process does not execute in explorer. i think it executes under WinLogon, maybe through a Winlogon notification package. i don't know which system call would trigger this behaviour automatically...
however, you can have a look at the Windows Update Agent API which should allow you to control automatic updates programmatically.
Im just throwing out some thoughts..
Maybe it puts an entry in this registry key before restarting: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce
Also check out the value ShutdownFlags in the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon