Skip to content

Commit b1d965a

Browse files
committed
Variable initialization refactored.
1 parent df17aa6 commit b1d965a

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

SrvCtrl.cpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,11 @@ int CSvrCtrl::Start(const wchar_t* szSvrName)
108108
if (SelfElevat() == true)
109109
return 0;
110110

111-
SC_HANDLE schService{ nullptr };
112-
SERVICE_STATUS_PROCESS ssStatus{ 0 };
113-
DWORD dwOldCheckPoint{ 0 };
114-
DWORD dwStartTickCount{ 0 };
115-
DWORD dwBytesNeeded{ 0 };
111+
SC_HANDLE schService{};
112+
SERVICE_STATUS_PROCESS ssStatus{};
113+
DWORD dwOldCheckPoint{};
114+
DWORD dwStartTickCount{};
115+
DWORD dwBytesNeeded{};
116116

117117
schService = OpenService(m_hSCManager, szSvrName, SERVICE_ALL_ACCESS);
118118

@@ -203,7 +203,7 @@ int CSvrCtrl::Stop(const wchar_t* szSvrName)
203203
if (schService == nullptr)
204204
return -5;
205205

206-
DWORD dwError{ 0 };
206+
DWORD dwError{};
207207
SERVICE_STATUS ssStatus;
208208
if (ControlService(schService, SERVICE_CONTROL_STOP, &ssStatus) == 0)
209209
dwError = GetLastError();
@@ -222,7 +222,7 @@ int CSvrCtrl::Pause(const wchar_t* szSvrName)
222222
if (schService == nullptr)
223223
return -5;
224224

225-
DWORD dwError{ 0 };
225+
DWORD dwError{};
226226
SERVICE_STATUS ssStatus;
227227
if (ControlService(schService, SERVICE_CONTROL_PAUSE, &ssStatus) == 0)
228228
dwError = GetLastError();
@@ -241,7 +241,7 @@ int CSvrCtrl::Continue(const wchar_t* szSvrName)
241241
if (schService == nullptr)
242242
return -5;
243243

244-
DWORD dwError{ 0 };
244+
DWORD dwError{};
245245
SERVICE_STATUS ssStatus;
246246
if (ControlService(schService, SERVICE_CONTROL_CONTINUE, &ssStatus) == 0)
247247
dwError = GetLastError();
@@ -319,9 +319,9 @@ bool CSvrCtrl::SelfElevat()
319319
return false;
320320

321321
// check if elevated on Vista and 7
322-
HANDLE Token{ nullptr };
323-
TOKEN_ELEVATION Elevation{ 0 }; // Token type only available with Vista/7
324-
DWORD ReturnSize{ 0 };
322+
HANDLE Token{};
323+
TOKEN_ELEVATION Elevation{}; // Token type only available with Vista/7
324+
DWORD ReturnSize{};
325325

326326
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_READ, &Token) ||
327327
!GetTokenInformation(Token, TokenElevation, &Elevation, sizeof(Elevation), &ReturnSize))

0 commit comments

Comments
 (0)