How can I put the code that can do the closing application and shutdown Windows 98 chores?
Printable View
How can I put the code that can do the closing application and shutdown Windows 98 chores?
Declare Function ExitWindowsEx Lib "user32.dll" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
ExitWindowsEx shuts down or reboots the user's computer. Of course, since the shutdown/reboot process will begin once the function is called, there won't normally be much left for your program to do. The function returns 0 if an error occured, or 1 if successful.
I am guessing you want to shutdown windows when your program closes... Anyway, the following code works well for me.
Create a new class file and name it ExitWindows. Put the following code into it.
Next, in your form, use the following:Code:'ExitWindows.cls
Option Explicit
Private Declare Function ExitWindowsEx Lib "user32" _
(ByVal uFlags As Long, ByVal dwReserved As Long) _
As Long
Private Const EWX_FORCE = 4
Private Const EWX_LOGOFF = 0
Private Const EWX_REBOOT = 2
Private Const EWX_SHUTDOWN = 1
'~~~Shutdown
Public Sub ShutDown()
ExitWindowsEx EWX_SHUTDOWN, 0
End Sub
'~~~Reboot
Public Sub Reboot()
ExitWindowsEx EWX_LOGOFF, 0
End Sub
'~~~Force Shutdown, closes all apps forcefully
Public Sub Force()
ExitWindowsEx EWX_FORCE, 0
End Sub
'~~~Logs the user off
Public Sub Logoff()
ExitWindowsEx EWX_LOGOFF, 0
End Sub
Hope this helps...Code:Dim exw as New ExitWindows
'To shutdown call this
exw.Shutdown
'To reboot call this
exw.Reboot
'To forecfully shutdown, call this
exw.Force
'And to logoff, call this
exw.Logoff
Laterz
REM :)