Ben Reynders
October 5th, 2001, 04:25 AM
How do I shutdown or log off a computer in win2000 (nt version). Can you give me a sample project. Thanks
|
Click to See Complete Forum and Search --> : Shutdown winnt Ben Reynders October 5th, 2001, 04:25 AM How do I shutdown or log off a computer in win2000 (nt version). Can you give me a sample project. Thanks Clearcode October 5th, 2001, 04:41 AM 'Declarations Declare Function ExitWindowsEx Lib "user32" Alias "ExitWindowsEx" (byval uFlags as Long, byval dwReserved as Long) as Long public Enum ExitWindowsFlags EWX_LOGOFF = 0 EWX_REBOOT = 2 EWX_SHUTDOWN = 1 EWX_FORCE = 4 End Enum and to use it: public Sub ExitWindows(byval Mode as ExitWindowsFlags) Call ExitWindowsEx(Mode,0) End Sub HTH, D. ------------------------------------------------- Ex. Datis: Duncan Jones Merrion Computing Ltd http://www.merrioncomputing.com Check out the new downloads - ImageMap.ocx is the VB control that emulates an HTML image map, EventVB.OCX for adding new events to your VB form and adding System Tray support simply, MCL Hotkey for implemenmting system-wide hotkeys in your application...all with source code included. deghost October 5th, 2001, 04:50 AM I don't think it works in Windows NT (or at least in 2000) does it? ... ---------- The @host is everywhere! ---------- Iouri October 5th, 2001, 07:09 AM 'Works only on NT Private Declare Function InitiateSystemShutdown Lib "advapi32.dll" Alias "InitiateSystemShutdownA" (ByVal lpMachineName As String, ByVal lpMessage As String, ByVal dwTimeout As Integer, ByVal bForceAppsClosed As Long, ByVal bRebootAfterShutdown As Long) As Long Private Declare Function AbortSystemShutdown Lib "advapi32.dll" Alias "AbortSystemShutdownA" (ByVal lpMachineName As String) As Long Public Function ShutDownComputer(CompName As String, MessageToUser As String, SecondsUntilShutdown As Long, ForceAppsClosed As Integer, RebootAfter As Integer) ShutDownComputer = InitiateSystemShutdown(CompName, MessageToUser, SecondsUntilShutdown, ForceAppsClosed, RebootAfter) End Function Public Function AbortShutdown(CompName As String) AbortShutdown = AbortSystemShutdown(CompName) End Function ' + Shutdown can only be aborted while the countdown is going. ' + Both Functions return "0" when failed, or "1" when Successful. Private Sub cmdAbort_Click() Call AbortShutdown(txtCompName) MsgBox "Shut down is aborted" End Sub Private Sub cmdExit_Click() Unload Me End Sub Private Sub cmdShut_Click() Dim Ret Dim msg As String msg = "Your Computer will be shut down in " & txtDelay & " sec." Ret = ShutDownComputer(txtCompName, msg, Val(txtDelay), 2, 5) Select Case Ret Case 0 MsgBox "Shut down failed." Case 1 MsgBox "Computer " & txtCompName & " is successfully shut down." End Select End Sub Iouri Boutchkine iouri@hotsheet.com codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |