LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Shutdown Windows with CVI application

How to notify the Windows system to shutdown with a CVI code ? When pressing the Alt-Ctrl-Del ,there always popup the system security window , I hope that I can program a code with cvi ,so when user pressing the combined key , the system can shutdown automatically without the security window . In addition , how to disable the combine key ?

By the way , if the function , InstallMainCallback() just can be called in the main() function ? I have called it in a subfunction , and expect it can generate a EVENT_END_TASK event , but it does nothing .

David
0 Kudos
Message 1 of 4
(3,585 Views)
That's a kernel level funcion and you can access that through the ADVAPI32.dll with the function call InitiateSystemShutdownA.

Alternatively use this NT4.0 executable.
Jattie van der Linde
Engineering Manager, Software & Automation
TEL Magnetic Solutions Ltd
0 Kudos
Message 2 of 4
(3,585 Views)
See also the Win32 SDK Function:

InitiateSystemShutdown

The InitiateSystemShutdown function initiates a shutdown and optional restart of the specified computer.

To record a reason for the shutdown in the event log, call the InitiateSystemShutdownEx function.

BOOL InitiateSystemShutdown(
LPTSTR lpMachineName, // computer name
LPTSTR lpMessage, // message to display
DWORD dwTimeout, // length of time to display
BOOL bForceAppsClosed, // force closed option
BOOL bRebootAfterShutdown // reboot option
);

Requirements
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Unsupported.
Windows CE: Unsupported.
Header: Declared in winreg.h; include windows.h.
Library: Use advap
i32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000.
Jattie van der Linde
Engineering Manager, Software & Automation
TEL Magnetic Solutions Ltd
0 Kudos
Message 3 of 4
(3,585 Views)
David,

For security reasons modern versions of windows (NT/2000/XP) will not allow you to block the Ctrl-Alt-Del key combination. You best bet is to install the main callback and wait for the EVENT_END_TASK, as long as you launch it from your main thread and not in a callback you should be able to install the callback and have you App detect when Windows is shutting down.

I'm not sure what is the security Window that you talk about, however it is possible that you can use the Windows SDK function FindWindow(,,,) to get a handle to that security window and send it a close message using PostMessage(,,,) with the message WM_CLOSE. This could force the window to quit and continue with the shutdown process.

Let us know if you have any questions on this.

Juan
Carlos
N.I.
0 Kudos
Message 4 of 4
(3,585 Views)