6 * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
43 ////////////////////////////////////////////////////////////////////////////////
47 static HANDLE hMonitorThreadEvent
= NULL
; // When this event becomes signaled then we run the monitor thread
49 void MonitorThreadProc(void *lpParameter
);
51 ////////////////////////////////////////////////////////////////////////////////
52 // Local module support methods
56 LRESULT CALLBACK
MoveDialogWndProc(HWND hDlg
, UINT message
, WPARAM wParam
, LPARAM lParam
)
59 TCHAR strLicense
[0x1000];
63 hLicenseEditWnd
= GetDlgItem(hDlg
, IDC_LICENSE_EDIT
);
64 LoadString(hInst
, IDS_LICENSE
, strLicense
, 0x1000);
65 SetWindowText(hLicenseEditWnd
, strLicense
);
68 if ((LOWORD(wParam
) == IDOK
) || (LOWORD(wParam
) == IDCANCEL
)) {
69 EndDialog(hDlg
, LOWORD(wParam
));
77 void StartWorkerThread(HWND hWnd
)
79 DialogBox(hInst
, MAKEINTRESOURCE(IDD_ABOUTBOX
), hWnd
, (DLGPROC
)MoveDialogWndProc
);
82 ////////////////////////////////////////////////////////////////////////////////
84 void MonitorThreadProc(void *lpParameter
)
86 // ULONG OldProcessorUsage = 0;
87 // ULONG OldProcessCount = 0;
88 HWND hWnd
= (HWND
)lpParameter
;
91 hMonitorThreadEvent
= CreateEvent(NULL
, TRUE
, TRUE
, _T("Winfile Monitor Event"));
93 // If we couldn't create the event then exit the thread
94 if (!hMonitorThreadEvent
)
101 dwWaitVal
= WaitForSingleObject(hMonitorThreadEvent
, INFINITE
);
103 // If the wait failed then the event object must have been
104 // closed and the task manager is exiting so exit this thread
105 if (dwWaitVal
== WAIT_FAILED
) {
106 // CloseHandle(hMonitorThreadEvent); // Should we close the event object handle or not ???
107 // hMonitorThreadEvent = NULL; // if we do then check what happens when main thread tries to delete it also....
111 if (dwWaitVal
== WAIT_OBJECT_0
) {
113 ResetEvent(hMonitorThreadEvent
);
116 ConfigureDriveBar(Globals
.hDriveBar
);
120 if ((ULONG
)SendMessage(hProcessPageListCtrl
, LVM_GETITEMCOUNT
, 0, 0) != PerfDataGetProcessCount())
121 SendMessage(hProcessPageListCtrl
, LVM_SETITEMCOUNT
, PerfDataGetProcessCount(), /*LVSICF_NOINVALIDATEALL|*/LVSICF_NOSCROLL
);
122 if (IsWindowVisible(hProcessPage
))
123 InvalidateRect(hProcessPageListCtrl
, NULL
, FALSE
);
124 if (OldProcessorUsage
!= PerfDataGetProcessorUsage()) {
125 OldProcessorUsage
= PerfDataGetProcessorUsage();
126 wsprintf(text
, _T("CPU Usage: %3d%%"), OldProcessorUsage
);
127 SendMessage(hStatusWnd
, SB_SETTEXT
, 1, (LPARAM
)text
);
129 if (OldProcessCount
!= PerfDataGetProcessCount()) {
130 OldProcessCount
= PerfDataGetProcessCount();
131 wsprintf(text
, _T("Processes: %d"), OldProcessCount
);
132 SendMessage(hStatusWnd
, SB_SETTEXT
, 0, (LPARAM
)text
);
139 BOOL
CreateMonitorThread(HWND hWnd
)
141 _beginthread(MonitorThreadProc
, 0, hWnd
);
145 void SignalMonitorEvent(void)
147 SetEvent(hMonitorThreadEvent
);
150 BOOL
DestryMonitorThread(void)
152 CloseHandle(hMonitorThreadEvent
);
153 hMonitorThreadEvent
= NULL
;