I want to perform a shutdown command through my database apps. Any ideas...?
Here is the code I wrote to logoff/reboot/shutdown. It is for MS access 95/97.
'*** cut here *** Option Compare Database Option Explicit Public Const EWX_LOGOFF = 0 ' Shuts down all processes running in the security context ' of the process that called the ExitWindowsEx function. ' Then it logs the user off. Public Const EWX_SHUTDOWN = 1 ' Shuts down the system and then restarts the system. ' The application must have the SE_SHUTDOWN_NAME privilege. Public Const EWX_REBOOT = 2 ' Shuts down the system to a point at which it is safe to ' turn off the power. All file buffers have been flushed to ' disk, and all running processes have stopped. ' The application must have the SE_SHUTDOWN_NAME privilege Public Const EWX_FORCE = 4 ' Forces processes to terminate. Instead of bringing up ' the "application not responding" dialog box for the user, ' this value forces an application to terminate if it does not respond. Public Const EWX_POWEROFF = 8 ' Shuts down the system and turns off the power. The application ' must have the SE_SHUTDOWN_NAME privilege ' and the system must support the power-off feature. Declare Function smsExitWindows Lib "user32" Alias "ExitWindows" (ByVal dwReserved As Long, ByVal uReturnCode As Long) As Long Declare Function smsExitWindowsEx Lib "user32" _ Alias "ExitWindowsEx" (ByVal uFlags As Long, _ ByVal dwReserved As Long) As Long Public Sub ByeWindowsTests(plngExitMode) Dim varDummy ''varDummy = smsExitWindowsEx(EWX_SHUTDOWN, 0&) '''varDummy = smsExitWindowsEx(EWX_REBOOT, 0&) '''varDummy = smsExitWindowsEx(EWX_LOGOFF, 0&) '''varDummy = smsExitWindowsEx(EWX_FORCE + EWX_POWEROFF + EWX_SHUTDOWN, 0&) varDummy = smsExitWindowsEx(plngExitMode, 0&) End Sub Public Function smsReboot() 'Call smsExitWindowsEx(EWX_SHUTDOWN Or EWX_FORCE, 0&) Call smsExitWindowsEx(EWX_REBOOT, 0&) End Function '*- cut here
Copyright © 1999-2008 by Shamil Salakhetdinov. All rights reserved.