ReactOS 0.4.15-dev-7704-gc07eb9f
hibernate.c File Reference
#include "powercfg.h"
Include dependency graph for hibernate.c:

Go to the source code of this file.

Functions

static VOID Hib_InitDialog (HWND hwndDlg)
 
INT_PTR Hib_SaveData (HWND hwndDlg)
 
INT_PTR CALLBACK HibernateDlgProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Function Documentation

◆ Hib_InitDialog()

static VOID Hib_InitDialog ( HWND  hwndDlg)
static

Definition at line 15 of file hibernate.c.

16{
18 MEMORYSTATUSEX msex;
19 TCHAR szTemp[MAX_PATH];
20 LPTSTR lpRoot;
21 ULARGE_INTEGER FreeBytesAvailable, TotalNumberOfBytes, TotalNumberOfFreeBytes;
22 BOOLEAN bHibernate;
23
24 if (GetPwrCapabilities(&PowerCaps))
25 {
26 CheckDlgButton(hwndDlg,
29
30 msex.dwLength = sizeof(msex);
31 if (!GlobalMemoryStatusEx(&msex))
32 {
33 return; // FIXME
34 }
35
36 if (GetWindowsDirectory(szTemp,MAX_PATH))
37 lpRoot = szTemp;
38 else
39 lpRoot = NULL;
40
41 // Get available space and size of selected volume.
42 if (!GetDiskFreeSpaceEx(lpRoot, &FreeBytesAvailable, &TotalNumberOfBytes, &TotalNumberOfFreeBytes))
43 TotalNumberOfFreeBytes.QuadPart = 0;
44
45 // Print the free available space into selected volume.
46 StrFormatByteSize(TotalNumberOfFreeBytes.QuadPart, szTemp, _countof(szTemp));
47 SetDlgItemText(hwndDlg, IDC_FREESPACE, szTemp);
48
49 // Print the amount of space required for hibernation.
50 StrFormatByteSize(msex.ullTotalPhys, szTemp, _countof(szTemp));
52
53 if (TotalNumberOfFreeBytes.QuadPart < msex.ullTotalPhys && !PowerCaps.HiberFilePresent)
54 {
57 }
58 else
59 {
62 }
63
64 bHibernate = PowerCaps.HiberFilePresent ? TRUE : FALSE;
65 if (CallNtPowerInformation(SystemReserveHiberFile, &bHibernate, sizeof(bHibernate), NULL, 0) != STATUS_SUCCESS)
66 {
68 }
69 }
70}
unsigned char BOOLEAN
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define IDC_HIBERNATEFILE
Definition: resource.h:105
#define IDC_FREESPACE
Definition: resource.h:106
#define IDC_TOLESSFREESPACE
Definition: resource.h:108
#define IDC_SPACEFORHIBERNATEFILE
Definition: resource.h:107
#define MAX_PATH
Definition: compat.h:34
BOOL NTAPI GlobalMemoryStatusEx(LPMEMORYSTATUSEX lpBuffer)
Definition: heapmem.c:1272
@ SystemReserveHiberFile
Definition: ntpoapi.h:77
BOOLEAN WINAPI GetPwrCapabilities(PSYSTEM_POWER_CAPABILITIES lpSystemPowerCapabilities)
Definition: powrprof.c:358
NTSTATUS WINAPI CallNtPowerInformation(POWER_INFORMATION_LEVEL InformationLevel, PVOID lpInputBuffer, ULONG nInputBufferSize, PVOID lpOutputBuffer, ULONG nOutputBufferSize)
Definition: powrprof.c:59
#define STATUS_SUCCESS
Definition: shellext.h:65
#define StrFormatByteSize
Definition: shlwapi.h:1566
#define _countof(array)
Definition: sndvol32.h:68
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
#define GetWindowsDirectory
Definition: winbase.h:3792
#define GetDiskFreeSpaceEx
Definition: winbase.h:3743
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI CheckDlgButton(_In_ HWND, _In_ int, _In_ UINT)
#define BST_UNCHECKED
Definition: winuser.h:199
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define SetDlgItemText
Definition: winuser.h:5848
#define BST_CHECKED
Definition: winuser.h:197
char TCHAR
Definition: xmlstorage.h:189
CHAR * LPTSTR
Definition: xmlstorage.h:192

Referenced by Hib_SaveData(), and HibernateDlgProc().

◆ Hib_SaveData()

INT_PTR Hib_SaveData ( HWND  hwndDlg)

Definition at line 73 of file hibernate.c.

74{
75 BOOLEAN bHibernate;
76
77 bHibernate = (BOOLEAN)(IsDlgButtonChecked(hwndDlg, IDC_HIBERNATEFILE) == BST_CHECKED);
78
79 if (CallNtPowerInformation(SystemReserveHiberFile, &bHibernate, sizeof(bHibernate), NULL, 0) == STATUS_SUCCESS)
80 {
81 Hib_InitDialog(hwndDlg);
82 return TRUE;
83 }
84
85 return FALSE;
86}
static VOID Hib_InitDialog(HWND hwndDlg)
Definition: hibernate.c:15
#define BOOLEAN
Definition: pedump.c:73
UINT WINAPI IsDlgButtonChecked(_In_ HWND, _In_ int)

Referenced by HibernateDlgProc().

◆ HibernateDlgProc()

INT_PTR CALLBACK HibernateDlgProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 90 of file hibernate.c.

94{
95 switch (uMsg)
96 {
97 case WM_INITDIALOG:
98 Hib_InitDialog(hwndDlg);
99 return TRUE;
100
101 case WM_COMMAND:
102 switch (LOWORD(wParam))
103 {
105 if (HIWORD(wParam) == BN_CLICKED)
106 {
107 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
108 }
109 break;
110 }
111 break;
112
113 case WM_NOTIFY:
114 if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY)
115 {
116 return Hib_SaveData(hwndDlg);
117 }
118 break;
119 }
120
121 return FALSE;
122}
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
INT_PTR Hib_SaveData(HWND hwndDlg)
Definition: hibernate.c:73
unsigned int UINT
Definition: ndis.h:50
#define LOWORD(l)
Definition: pedump.c:82
#define PropSheet_Changed(d, w)
Definition: prsht.h:344
#define PSN_APPLY
Definition: prsht.h:117
#define WM_NOTIFY
Definition: richedit.h:61
Definition: inflate.c:139
#define HIWORD(l)
Definition: typedefs.h:247
#define WM_COMMAND
Definition: winuser.h:1739
#define WM_INITDIALOG
Definition: winuser.h:1738
HWND WINAPI GetParent(_In_ HWND)
#define BN_CLICKED
Definition: winuser.h:1924

Referenced by Applet1().