Click here to Skip to main content
15,913,941 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Iterating over Dialog? Pin
Ravi Bhavnani25-Jan-07 5:41
professionalRavi Bhavnani25-Jan-07 5:41 
GeneralRe: Iterating over Dialog? Pin
bosfan25-Jan-07 5:48
bosfan25-Jan-07 5:48 
AnswerRe: Iterating over Dialog? Pin
Roger Stoltz25-Jan-07 6:05
Roger Stoltz25-Jan-07 6:05 
AnswerRe: Iterating over Dialog? Pin
#realJSOP25-Jan-07 8:26
professional#realJSOP25-Jan-07 8:26 
QuestionUgh! Resource problems and 'Clean-up' tools Pin
Like2Byte25-Jan-07 3:25
Like2Byte25-Jan-07 3:25 
AnswerRe: Ugh! Resource problems and 'Clean-up' tools Pin
Maximilien25-Jan-07 4:17
Maximilien25-Jan-07 4:17 
GeneralRe: Ugh! Resource problems and 'Clean-up' tools Pin
Like2Byte25-Jan-07 4:18
Like2Byte25-Jan-07 4:18 
QuestionReturning an error from service stop Pin
sharon_cds25-Jan-07 2:29
sharon_cds25-Jan-07 2:29 
Hi,
I have a service written in C++. When I get SERVICE_CONTROL_STOP command, I want to check certain condition and if that condition is false then return an error and not stop the service.
In the service control handler function (registered by RegisterServiceCtrlHandler), I have a code which looks as follows:

void service_ctrl(DWORD dwCtrlCode)
{
...
switch(dwCtrlCode)
{
....
case SERVICE_CONTROL_STOP:
if ( CanStop() == FALSE )
{
// stop not allowed.
ssStatus.dwCurrentState = SERVICE_RUNNING;
ssStatus.dwWin32ExitCode = NO_ERROR;
ssStatus.dwCheckPoint = 0;
if (!(fResult = SetServiceStatus(
sshStatusHandle, // service reference handle
&ssStatus))) { // SERVICE_STATUS structure
// LOG SOME ERROR
}
}
else
{
// stop allowed.
....
}
break;
}
...
}

The problem is:
When I stop the service, by running "net stop MyService", it displays "service could not be stopped", the service status remains "started" and this is great.
But when I run "net stop MyService" again, it displays "The service could not be controlled in its present state" and the service status becomes blank.
How should I decline service stop request properly?
AnswerRe: Returning an error from service stop Pin
Mark Salsbery25-Jan-07 5:56
Mark Salsbery25-Jan-07 5:56 
QuestionProblem! Pin
baby_fong8225-Jan-07 2:20
baby_fong8225-Jan-07 2:20 
AnswerRe: Problem! Pin
Mark Salsbery25-Jan-07 5:58
Mark Salsbery25-Jan-07 5:58 
Questionhow to Build a reguler Dll( unicode competable) in vc++ Pin
singh_nav25-Jan-07 2:15
singh_nav25-Jan-07 2:15 
QuestionRe: how to Build a reguler Dll( unicode competable) in vc++ Pin
prasad_som25-Jan-07 2:57
prasad_som25-Jan-07 2:57 
AnswerRe: how to Build a reguler Dll( unicode competable) in vc++ Pin
singh_nav29-Jan-07 0:31
singh_nav29-Jan-07 0:31 
QuestionDrawing with dll Pin
mk7925-Jan-07 0:56
mk7925-Jan-07 0:56 
QuestionRe: Drawing with dll Pin
prasad_som25-Jan-07 0:59
prasad_som25-Jan-07 0:59 
AnswerRe: Drawing with dll Pin
CPallini25-Jan-07 1:37
mveCPallini25-Jan-07 1:37 
AnswerRe: Drawing with dll Pin
Hamid_RT25-Jan-07 21:00
Hamid_RT25-Jan-07 21:00 
QuestionTo find difference dates Pin
johnalek25-Jan-07 0:50
johnalek25-Jan-07 0:50 
QuestionRe: To find difference dates Pin
prasad_som25-Jan-07 0:57
prasad_som25-Jan-07 0:57 
AnswerRe: To find difference dates Pin
johnalek25-Jan-07 1:20
johnalek25-Jan-07 1:20 
QuestionRe: To find difference dates Pin
prasad_som25-Jan-07 1:46
prasad_som25-Jan-07 1:46 
GeneralRe: To find difference dates Pin
David Crow25-Jan-07 2:56
David Crow25-Jan-07 2:56 
QuestionRe: To find difference dates Pin
David Crow25-Jan-07 2:55
David Crow25-Jan-07 2:55 
AnswerRe: To find difference dates Pin
Sergey Kolomenkin25-Jan-07 8:33
Sergey Kolomenkin25-Jan-07 8:33 

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.