Skip to content

Commit 494f107

Browse files
committed
Merge remote-tracking branch 'gcranston/master' into #2-hibernate
2 parents c52f1bf + 0db1219 commit 494f107

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

WinNUT_V2/WinNUT_GUI/Shutdown_Gui.vb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ Public Class Shutdown_Gui
102102
System.Threading.Thread.Sleep(1000)
103103
WinNUT.Shutdown_Action()
104104
Run_Timer.Enabled = False
105+
Me.Shutdown_Timer.Stop()
106+
Me.Shutdown_Timer.Enabled = False
107+
Me.Grace_Timer.Stop()
108+
Me.Grace_Timer.Enabled = False
109+
Me.Hide()
110+
Me.Close()
105111
End Sub
106112

107113
Private Sub Run_Timer_Tick(sender As Object, e As EventArgs) Handles Run_Timer.Tick

WinNUT_V2/WinNUT_GUI/WinNUT.vb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ Public Class WinNUT
6262
Private Event On_Battery()
6363
Private Event On_Line()
6464
Private Event Data_Updated()
65-
Private Shared Event UpdateNotifyIconStr(ByVal Reason As String, ByVal Message As String)
66-
Private Shared Event UpdateBatteryState(ByVal Reason As String)
65+
Private Event UpdateNotifyIconStr(ByVal Reason As String, ByVal Message As String)
66+
Private Event UpdateBatteryState(ByVal Reason As String)
6767

6868
'Handle sleep/hibernate mode from windows API
69-
Declare Function SetSystemPowerState Lib "kernel32" (ByVal fSuspend As Integer, ByVal fForce As Integer) As Integer
69+
Declare Function SetSuspendState Lib "PowrProf" (ByVal Hibernate As Integer, ByVal ForceCritical As Integer, ByVal DisableWakeEvent As Integer) As Integer
7070

7171
Public Property UpdateMethod() As String
7272
Get
@@ -1039,9 +1039,9 @@ Public Class WinNUT
10391039
Case 0
10401040
Process.Start("C:\WINDOWS\system32\Shutdown.exe", "-f -s -t 0")
10411041
Case 1
1042-
SetSystemPowerState(True, 0)
1042+
SetSuspendState(False, False, True) 'Suspend
10431043
Case 2
1044-
SetSystemPowerState(False, 0)
1044+
SetSuspendState(True, False, True) 'Hibernate
10451045
End Select
10461046
End Sub
10471047

0 commit comments

Comments
 (0)