Shut MSVC warnings up

svn path=/trunk/; revision=20339
This commit is contained in:
Ged Murphy 2005-12-26 20:40:45 +00:00
parent 5159234db2
commit 742f2e36bf
3 changed files with 24 additions and 23 deletions

View file

@ -16,9 +16,12 @@
#include "sc.h" #include "sc.h"
#define DEBUG
#include <debug.h>
/* local function decs */ /* local function decs */
VOID PrintService(BOOL bExtended); VOID PrintService(BOOL bExtended);
BOOL EnumServices(LPCTSTR ServiceName, DWORD ServiceType, DWORD ServiceState); BOOL EnumServices(DWORD ServiceType, DWORD ServiceState);
BOOL QueryService(LPCTSTR ServiceName, BOOL bExtended); BOOL QueryService(LPCTSTR ServiceName, BOOL bExtended);
/* global variables */ /* global variables */
@ -29,11 +32,10 @@ DWORD NumServices = 0;
BOOL BOOL
Query(LPCTSTR ServiceName, LPCTSTR *ServiceArgs, BOOL bExtended) Query(LPCTSTR ServiceName, LPCTSTR *ServiceArgs, BOOL bExtended)
{ {
if (! ServiceName) /* display all running services and drivers */ if (! ServiceName) /* display all running services and drivers */
{ {
/* get default values */ /* get default values */
EnumServices(NULL, SERVICE_WIN32, SERVICE_ACTIVE); EnumServices(SERVICE_WIN32, SERVICE_ACTIVE);
/* print default values */ /* print default values */
PrintService(bExtended); PrintService(bExtended);
@ -43,11 +45,11 @@ Query(LPCTSTR ServiceName, LPCTSTR *ServiceArgs, BOOL bExtended)
LPCTSTR Type = *ServiceArgs; LPCTSTR Type = *ServiceArgs;
if (_tcsicmp(Type, _T("driver")) == 0) if (_tcsicmp(Type, _T("driver")) == 0)
EnumServices(NULL, SERVICE_DRIVER, SERVICE_ACTIVE); EnumServices(SERVICE_DRIVER, SERVICE_ACTIVE);
else if (_tcsicmp(Type, _T("service")) == 0) else if (_tcsicmp(Type, _T("service")) == 0)
EnumServices(NULL, SERVICE_WIN32, SERVICE_ACTIVE); EnumServices(SERVICE_WIN32, SERVICE_ACTIVE);
else if (_tcsicmp(Type, _T("all")) == 0) else if (_tcsicmp(Type, _T("all")) == 0)
EnumServices(NULL, SERVICE_DRIVER|SERVICE_WIN32, SERVICE_ACTIVE); EnumServices(SERVICE_DRIVER|SERVICE_WIN32, SERVICE_ACTIVE);
else else
{ {
_tprintf(_T("\nERROR following \"type=\"!\n")); _tprintf(_T("\nERROR following \"type=\"!\n"));
@ -61,9 +63,9 @@ Query(LPCTSTR ServiceName, LPCTSTR *ServiceArgs, BOOL bExtended)
LPCTSTR State = *ServiceArgs; LPCTSTR State = *ServiceArgs;
if (_tcsicmp(State, _T("inactive")) == 0) if (_tcsicmp(State, _T("inactive")) == 0)
EnumServices(NULL, SERVICE_WIN32, SERVICE_INACTIVE); EnumServices(SERVICE_WIN32, SERVICE_INACTIVE);
else if (_tcsicmp(State, _T("all")) == 0) else if (_tcsicmp(State, _T("all")) == 0)
EnumServices(NULL, SERVICE_WIN32, SERVICE_STATE_ALL); EnumServices(SERVICE_WIN32, SERVICE_STATE_ALL);
else else
{ {
_tprintf(_T("\nERROR following \"state=\"!\n")); _tprintf(_T("\nERROR following \"state=\"!\n"));
@ -202,7 +204,7 @@ QueryService(LPCTSTR ServiceName, BOOL bExtended)
BOOL BOOL
EnumServices(LPCTSTR ServiceName, DWORD ServiceType, DWORD ServiceState) EnumServices(DWORD ServiceType, DWORD ServiceState)
{ {
DWORD BufSize = 0; DWORD BufSize = 0;
DWORD BytesNeeded = 0; DWORD BytesNeeded = 0;
@ -265,7 +267,7 @@ EnumServices(LPCTSTR ServiceName, DWORD ServiceType, DWORD ServiceState)
VOID VOID
PrintService(BOOL bExtended) PrintService(BOOL bExtended)
{ {
int i; DWORD i;
for (i=0; i < NumServices; i++) for (i=0; i < NumServices; i++)
{ {

View file

@ -21,8 +21,7 @@ DWORD ReportLastError(VOID)
DWORD ErrorCode = GetLastError(); DWORD ErrorCode = GetLastError();
if (ErrorCode != ERROR_SUCCESS) if (ErrorCode != ERROR_SUCCESS)
{ {
if ((RetVal = FormatMessage( RetVal = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, NULL,
@ -30,7 +29,9 @@ DWORD ReportLastError(VOID)
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */
(LPTSTR) &lpMsgBuf, (LPTSTR) &lpMsgBuf,
0, 0,
NULL ))) NULL );
if (RetVal != 0)
{ {
_tprintf(_T("%s"), (LPTSTR)lpMsgBuf); _tprintf(_T("%s"), (LPTSTR)lpMsgBuf);
@ -169,8 +170,6 @@ int _tmain(int argc, LPCTSTR argv[])
ServiceName = argv[2]; ServiceName = argv[2];
return ScControl(MachineName, Command, ServiceName, &argv[3], argc); return ScControl(MachineName, Command, ServiceName, &argv[3], argc);
} }
return MainUsage();
} }

View file

@ -13,7 +13,7 @@
INT MainUsage(VOID) INT MainUsage(VOID)
{ {
TCHAR c; INT c;
_tprintf(_T("DESCRIPTION:\n") _tprintf(_T("DESCRIPTION:\n")
_T("\tSC is a command line program used for communicating with\n") _T("\tSC is a command line program used for communicating with\n")