|
-
Jun 17th, 2000, 01:05 PM
#1
Thread Starter
Lively Member
How can I put the code that can do the closing application and shutdown Windows 98 chores?
-
Jun 17th, 2000, 03:40 PM
#2
New Member
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.
-
Jun 17th, 2000, 04:46 PM
#3
Lively Member
This may help
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.
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
Next, in your form, use the following:
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
Hope this helps...
Laterz
REM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|