char PleaseCheckEV[]="Please check the Event Viewer for more information.";
char MsgTextFormat[] = "Error code %d\n%s\n%s";
int
StartupService(char *Service, int* pErrorCode)
{
int retvalue = 0x0;
SC_HANDLE hSCMDB;
SC_HANDLE hService;
SERVICE_STATUS ServiceStatus;
int i;
*pErrorCode = ERROR_SUCCESS;
/* open the active db on the local computer */
hSCMDB = OpenSCManager(NULL,NULL,SC_MANAGER_ALL_ACCESS);
if ( !hSCMDB )
{
*pErrorCode = GetLastError();
}
else /* success */
{
hService = OpenService(hSCMDB,Service,SERVICE_ALL_ACCESS);
if ( !hService )
{
*pErrorCode = GetLastError();
}
else
{
if ( StartService(hService,0x0,NULL) )
{
Sleep(0x3E8);
i = 10;
do
{
if ( QueryServiceStatus(hService,&ServiceStatus) )
{
if ( ServiceStatus.dwCurrentState != SERVICE_START_PENDING )
break;
char* pErrorMsg;
int ErrorCode;
int i;
char* pMsgText;
if ( StartupService("NTICE",&ErrorCode) ) /* success */
return TRUE;
else
{
/*
if NTICE has not been started, tell us why...
*/
if ( FormatMessage(
FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_IGNORE_INSERTS, NULL, ErrorCode,LANG_SYSTEM_DEFAULT,&pErrorMsg,0x0,NULL) )
{
i = strlen(PleaseCheckEV);
i += strlen(pErrorMsg);
i += 0x30; /* large for avoiding overflow */