Click here to Skip to main content
15,895,833 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to use help file Pin
Hans Dietrich25-May-11 17:04
mentorHans Dietrich25-May-11 17:04 
AnswerRe: How to use help file Pin
వేంకటనారాయణ(venkatmakam)25-May-11 19:19
వేంకటనారాయణ(venkatmakam)25-May-11 19:19 
QuestionEdit message in CListCtrl Pin
_Flaviu25-May-11 1:53
_Flaviu25-May-11 1:53 
AnswerRe: Edit message in CListCtrl Pin
Richard MacCutchan25-May-11 2:48
mveRichard MacCutchan25-May-11 2:48 
AnswerRe: Edit message in CListCtrl Pin
Malli_S25-May-11 3:14
Malli_S25-May-11 3:14 
AnswerRe: Edit message in CListCtrl Pin
వేంకటనారాయణ(venkatmakam)25-May-11 3:23
వేంకటనారాయణ(venkatmakam)25-May-11 3:23 
GeneralRe: Edit message in CListCtrl Pin
_Flaviu25-May-11 6:16
_Flaviu25-May-11 6:16 
QuestionWhile going from Paused to Stopped, the Service Hangs at Stopping Pin
SunilKrSingh25-May-11 0:03
SunilKrSingh25-May-11 0:03 
While going from Paused to Stopped the Service Status Hangs at Stopping, eventually timing out and receiving an error message.
Error 1053: The service did not respond to the start or control request in a timely fashion.

Following code is causing the service to go into not responding state when going from paused to Stopped state.

Can anyone plz help me in finding out whats wrong with the code?

When I use SERVICE_CONTROL_STOP instead of SERVICE_STOP_PENDING in the method SendStatusToSCM, it resolves the issue. Is this correct way?

VOID Handler (DWORD controlCode)
{
DWORD currentState = 0;
BOOL success;
switch(controlCode)
{
// Stop the service
case SERVICE_CONTROL_STOP:
{
success = SendStatusToSCM(SERVICE_STOP_PENDING,
NO_ERROR, 0, 1, 5000);
}
break;

// Pause the service
case SERVICE_CONTROL_PAUSE:
if (runningService && !pauseService)
{
// Tell the SCM what's happening
success = SendStatusToSCM(
SERVICE_PAUSE_PENDING,
NO_ERROR, 0, 1, 1000);
pauseService = TRUE;
SuspendThread(threadHandle);
currentState = SERVICE_PAUSED;
}
break;
}

BOOL SendStatusToSCM (DWORD dwCurrentState,
DWORD dwWin32ExitCode,
DWORD dwServiceSpecificExitCode,
DWORD dwCheckPoint,
DWORD dwWaitHint)
{
BOOL success;
SERVICE_STATUS serviceStatus;

// Fill in all of the SERVICE_STATUS fields
serviceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
serviceStatus.dwCurrentState = dwCurrentState;

// If in the process of doing something, then accept
// no control events, else accept anything
if (dwCurrentState == SERVICE_START_PENDING)
serviceStatus.dwControlsAccepted = 0;
else
serviceStatus.dwControlsAccepted =
SERVICE_ACCEPT_STOP |
SERVICE_ACCEPT_PAUSE_CONTINUE |
SERVICE_ACCEPT_SHUTDOWN;

// if a specific exit code is defined, set up
// the win32 exit code properly
if (dwServiceSpecificExitCode == 0)
serviceStatus.dwWin32ExitCode = dwWin32ExitCode;
else
serviceStatus.dwWin32ExitCode =
ERROR_SERVICE_SPECIFIC_ERROR;
serviceStatus.dwServiceSpecificExitCode =
dwServiceSpecificExitCode;

serviceStatus.dwCheckPoint = dwCheckPoint;
serviceStatus.dwWaitHint = dwWaitHint;

// Pass the status record to the SCM
success = SetServiceStatus (serviceStatusHandle,
&serviceStatus);
return success;
}
QuestionRe: While going from Paused to Stopped, the Service Hangs at Stopping Pin
Malli_S25-May-11 3:19
Malli_S25-May-11 3:19 
QuestionRe: While going from Paused to Stopped, the Service Hangs at Stopping Pin
Mark Salsbery25-May-11 7:03
Mark Salsbery25-May-11 7:03 
AnswerRe: While going from Paused to Stopped, the Service Hangs at Stopping Pin
jschell25-May-11 10:10
jschell25-May-11 10:10 
GeneralRe: While going from Paused to Stopped, the Service Hangs at Stopping Pin
SunilKrSingh26-May-11 2:05
SunilKrSingh26-May-11 2:05 
QuestionIs it possible to change linked-text color for CRichEditCtrl? Pin
includeh1024-May-11 23:59
includeh1024-May-11 23:59 
AnswerRe: Is it possible to change linked-text color for CRichEditCtrl? Pin
tagopi25-May-11 0:37
tagopi25-May-11 0:37 
QuestionHow to remove the "0" from the starting i.e. from the left of the CString Pin
deadlyabbas24-May-11 22:20
deadlyabbas24-May-11 22:20 
AnswerRe: How to remove the "0" from the starting i.e. from the left of the CString Pin
Prasann Mayekar24-May-11 22:24
Prasann Mayekar24-May-11 22:24 
AnswerRe: How to remove the "0" from the starting i.e. from the left of the CString Pin
Code-o-mat24-May-11 22:31
Code-o-mat24-May-11 22:31 
AnswerRe: How to remove the "0" from the starting i.e. from the left of the CString Pin
_AnsHUMAN_ 25-May-11 1:23
_AnsHUMAN_ 25-May-11 1:23 
QuestionWeird ::CopyFile problem Pin
od@ananzi.co.za24-May-11 21:03
od@ananzi.co.za24-May-11 21:03 
AnswerRe: Weird ::CopyFile problem Pin
ShilpiP24-May-11 21:15
ShilpiP24-May-11 21:15 
GeneralRe: Weird ::CopyFile problem Pin
od@ananzi.co.za24-May-11 21:25
od@ananzi.co.za24-May-11 21:25 
GeneralRe: Weird ::CopyFile problem Pin
ShilpiP24-May-11 21:38
ShilpiP24-May-11 21:38 
GeneralRe: Weird ::CopyFile problem Pin
od@ananzi.co.za24-May-11 21:43
od@ananzi.co.za24-May-11 21:43 
GeneralRe: Weird ::CopyFile problem Pin
ShilpiP24-May-11 22:19
ShilpiP24-May-11 22:19 
GeneralRe: Weird ::CopyFile problem Pin
smags1325-May-11 10:28
smags1325-May-11 10:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.