Click here to Skip to main content
15,896,527 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Delaying Shutdown through windows service and executing scripts ? Pin
Covean22-Oct-09 3:42
Covean22-Oct-09 3:42 
GeneralRe: Delaying Shutdown through windows service and executing scripts ? Pin
Kushagra Tiwari22-Oct-09 3:48
Kushagra Tiwari22-Oct-09 3:48 
QuestionRe: Delaying Shutdown through windows service and executing scripts ? Pin
David Crow22-Oct-09 4:01
David Crow22-Oct-09 4:01 
AnswerRe: Delaying Shutdown through windows service and executing scripts ? Pin
Covean22-Oct-09 4:08
Covean22-Oct-09 4:08 
QuestionRe: Delaying Shutdown through windows service and executing scripts ? [modified] Pin
Kushagra Tiwari22-Oct-09 5:11
Kushagra Tiwari22-Oct-09 5:11 
AnswerRe: Delaying Shutdown through windows service and executing scripts ? [modified] Pin
Covean22-Oct-09 5:50
Covean22-Oct-09 5:50 
GeneralRe: Delaying Shutdown through windows service and executing scripts ? Pin
Kushagra Tiwari22-Oct-09 6:46
Kushagra Tiwari22-Oct-09 6:46 
QuestionRe: Delaying Shutdown through windows service and executing scripts ? Pin
Kushagra Tiwari22-Oct-09 21:10
Kushagra Tiwari22-Oct-09 21:10 
Covean wrote:
. You have to use SetServiceStatus with a SERVICE_STATUS where dwControlsAccepted is a least SERVICE_ACCEPT_SHUTDOWN.


As per ur suggestion I tried to do the same but seems the control never reaches my code , I am quite confused actually as I think I am doing every thing which I think is right .Here is what I am doing after calling RegisterserverEx:

::SetServiceStatus(m_hServiceStatus, &m_status);
Where m_status is of SERVICE_STATUS type and initialized by :

m_status.dwServiceType = SERVICE_WIN32_OWN_PROCESS|SERVICE_INTERACTIVE_PROCESS;
m_status.dwCurrentState = SERVICE_STOPPED;
m_status.dwControlsAccepted = SERVICE_ACCEPT_STOP|SERVICE_ACCEPT_SHUTDOWN;
m_status.dwWin32ExitCode = 0;
m_status.dwServiceSpecificExitCode = 0;
m_status.dwCheckPoint = 0;
m_status.dwWaitHint = 0;

and in Handler function of my Service handle SERVICE_CONTROL_SHUTDOWN which has following code

char chComputerName[512];
DWORD dwBuff = 512;
GetComputerName(chComputerName,&dwBuff);
switch (dwOpcode)
{
case SERVICE_CONTROL_STOP:
SetServiceStatus(SERVICE_STOP_PENDING);
Alive = true;
iscmcontrol = 3;
PostThreadMessage(dwThreadID, WM_QUIT, 0, 0);
break;
case SERVICE_CONTROL_PAUSE:
Alive = false;
iscmcontrol = 1;
break;
case SERVICE_CONTROL_CONTINUE:
Alive = false;
iscmcontrol = 0;
break;
case SERVICE_CONTROL_INTERROGATE:
break;
case SERVICE_CONTROL_SHUTDOWN:

CoInitialize( NULL );
AbortShutdown(chComputerName);
CoUninitialize();
Alive = true;
iscmcontrol = 2;
break;
default:
LogEvent(_T("Bad service request"));
}


If you want the sample code and personally see what is the problem please let me know your email address I will send it to you .

Regards,
Kushagra
GeneralRe: Delaying Shutdown through windows service and executing scripts ? Pin
Kushagra Tiwari22-Oct-09 23:29
Kushagra Tiwari22-Oct-09 23:29 
GeneralRe: Delaying Shutdown through windows service and executing scripts ? Pin
Covean23-Oct-09 0:31
Covean23-Oct-09 0:31 
GeneralRe: Delaying Shutdown through windows service and executing scripts ? Pin
Kushagra Tiwari23-Oct-09 0:39
Kushagra Tiwari23-Oct-09 0:39 
QuestionRe: Delaying Shutdown through windows service and executing scripts ? Pin
Kushagra Tiwari23-Oct-09 2:12
Kushagra Tiwari23-Oct-09 2:12 
AnswerRe: Delaying Shutdown through windows service and executing scripts ? Pin
Covean23-Oct-09 2:40
Covean23-Oct-09 2:40 
GeneralRe: Delaying Shutdown through windows service and executing scripts ? Pin
Kushagra Tiwari23-Oct-09 3:01
Kushagra Tiwari23-Oct-09 3:01 
QuestionRe: Delaying Shutdown through windows service and executing scripts ? Pin
Kushagra Tiwari26-Oct-09 1:28
Kushagra Tiwari26-Oct-09 1:28 
AnswerRe: Delaying Shutdown through windows service and executing scripts ? Pin
Covean26-Oct-09 4:05
Covean26-Oct-09 4:05 
AnswerRe: Delaying Shutdown through windows service and executing scripts ? Pin
Kushagra Tiwari26-Oct-09 20:21
Kushagra Tiwari26-Oct-09 20:21 
QuestionSYBASE's Functions giving LOGIN CRASH problem in VC++ code Pin
Vetukuri Raju22-Oct-09 1:59
Vetukuri Raju22-Oct-09 1:59 
GeneralRe: SYBASE's Functions giving LOGIN CRASH problem in VC++ code Pin
CPallini22-Oct-09 2:33
mveCPallini22-Oct-09 2:33 
QuestionVisual C++ Express, No MFC? Does that matter? Pin
mtthw22-Oct-09 1:51
mtthw22-Oct-09 1:51 
AnswerRe: Visual C++ Express, No MFC? Does that matter? Pin
CPallini22-Oct-09 1:53
mveCPallini22-Oct-09 1:53 
GeneralRe: Visual C++ Express, No MFC? Does that matter? Pin
mtthw22-Oct-09 11:02
mtthw22-Oct-09 11:02 
AnswerRe: Visual C++ Express, No MFC? Does that matter? Pin
Maximilien22-Oct-09 2:45
Maximilien22-Oct-09 2:45 
GeneralRe: Visual C++ Express, No MFC? Does that matter? Pin
mtthw22-Oct-09 11:11
mtthw22-Oct-09 11:11 
AnswerRe: Visual C++ Express, No MFC? Does that matter? Pin
Richard MacCutchan22-Oct-09 2:47
mveRichard MacCutchan22-Oct-09 2:47 

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.