forked from bigmacd/trapreceiver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrMonitor.cpp
More file actions
111 lines (83 loc) · 1.89 KB
/
TrMonitor.cpp
File metadata and controls
111 lines (83 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#include "stdafx.h"
#include "TrMonitor.h"
TrMonitor::TrMonitor(unsigned long waitHint)
: CDialog(TrMonitor::IDD, NULL),
mWaitHint(waitHint),
mScManager(NULL),
mService(NULL)
{
// if (mWaitHint > 100)
// mWaitHint = 100;
mWaitHint = 15; // new functionality
mScManager = OpenSCManager(NULL,
NULL,
NULL);
if (mScManager == NULL)
EndDialog(0);
mService = OpenService(mScManager,
"TrapRcvr",
SERVICE_ALL_ACCESS);
if (mService == NULL)
EndDialog(0);
//{{AFX_DATA_INIT(TrMonitor)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void
TrMonitor::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(TrMonitor)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(TrMonitor, CDialog)
//{{AFX_MSG_MAP(TrMonitor)
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void
TrMonitor::OnTimer(UINT nIDEvent)
{
CDialog::OnTimer(nIDEvent);
if (nIDEvent == TRMONITORTIMERID)
{
if (!QueryServiceStatus(mService,
&mScs))
{
KillTimer(TRMONITORTIMERID);
EndDialog(0);
}
if (mScs.dwCurrentState == SERVICE_RUNNING)
{
KillTimer(TRMONITORTIMERID);
EndDialog(0);
}
CWnd* cwnd = GetDlgItem(IDC_PROGRESS);
CProgressCtrl* p = (CProgressCtrl*)cwnd;
p->StepIt();
mWaitHint--;
if (!mWaitHint)
{
}
}
}
BOOL
TrMonitor::OnInitDialog()
{
CDialog::OnInitDialog();
mCursor = AfxGetApp()->LoadStandardCursor(IDC_WAIT);
CWnd* cwnd = GetDlgItem(IDC_PROGRESS);
CProgressCtrl* p = (CProgressCtrl*)cwnd;
p->SetRange(1, (int)mWaitHint);
p->SetPos(1);
p->SetStep(1);
SetTimer(TRMONITORTIMERID, 1000, NULL);
return TRUE;
}
BOOL TrMonitor::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message == WM_KEYDOWN ||
pMsg->message == WM_SYSKEYDOWN)
return TRUE;
return CDialog::PreTranslateMessage(pMsg);
}