Click here to Skip to main content
15,918,268 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Derive Class from CTime Pin
Naveen28-Feb-07 22:32
Naveen28-Feb-07 22:32 
GeneralRe: Derive Class from CTime Pin
e-DJ28-Feb-07 23:34
e-DJ28-Feb-07 23:34 
GeneralRe: Derive Class from CTime Pin
Naveen1-Mar-07 0:21
Naveen1-Mar-07 0:21 
GeneralRe: Derive Class from CTime Pin
e-DJ1-Mar-07 4:19
e-DJ1-Mar-07 4:19 
AnswerRe: Derive Class from CTime Pin
Nibu babu thomas28-Feb-07 22:55
Nibu babu thomas28-Feb-07 22:55 
GeneralRe: Derive Class from CTime Pin
e-DJ28-Feb-07 23:48
e-DJ28-Feb-07 23:48 
AnswerRe: Derive Class from CTime Pin
David Crow1-Mar-07 2:39
David Crow1-Mar-07 2:39 
QuestionWin Service problem Pin
david bagaturia28-Feb-07 21:38
david bagaturia28-Feb-07 21:38 
Hi all.

I write win service and I have simple code:
<br />
void main(void)<br />
{<br />
  SERVICE_TABLE_ENTRY DispatcherTable[] =<br />
  {<br />
    {<br />
          (LPWSTR)MYServiceName,<br />
          (LPSERVICE_MAIN_FUNCTION)ServiceMain<br />
    },<br />
    {<br />
      NULL,<br />
      NULL<br />
    }<br />
  };<br />
<br />
  printf("Sample of simple service\n(C) D. Bagaturia, 2007, Email: dato_baga@mail.ru\n");<br />
<br />
<br />
  if(!StartServiceCtrlDispatcher(DispatcherTable))<br />
  {<br />
   CloseHandle(hMutex);<br />
    return;<br />
  }<br />
<br />
}<br />


Problem is that: Wen 'ServiceMain' function ends control go to main() function, and wen main() ends program ends, sow I get thet my service works less than second.

I try to write:

<br />
void main(void)<br />
{<br />
  HANDEL hThread;<br />
  SERVICE_TABLE_ENTRY DispatcherTable[] =<br />
  {<br />
    {<br />
          (LPWSTR)MYServiceName,<br />
          (LPSERVICE_MAIN_FUNCTION)ServiceMain<br />
    },<br />
    {<br />
      NULL,<br />
      NULL<br />
    }<br />
  };<br />
<br />
  printf("Sample of simple service\n(C) D. Bagaturia, 2007, Email: dato_baga@mail.ru\n");<br />
<br />
<br />
  if(!StartServiceCtrlDispatcher(DispatcherTable))<br />
  {<br />
   CloseHandle(hMutex);<br />
    return;<br />
  }<br />
<br />
//I add this part<br />
do{<br />
	 GetExitCodeThread(hThread, // some thread <br />
			   lpExitCode);<br />
	 //this thread starts in ServiceMain Function<br />
	 if(*lpExitCode == STILL_ACTIVE)<br />
		 Sleep(150);<br />
	 else<br />
		 break;<br />
		 <br />
  }while(1);<br />
<br />
}<br />

But in this time I get runtime error.
Wen I try to start or stop my service in ServiceManager, I get error message.

I know thet I blocked the service in case two, but I need this service more then 1 second.

Sow I have:
case 1: service runs less 1 second.
case 2: service runs but, it is blocked.

I know that I made som mistake, but whot?
AnswerRe: Win Service problem Pin
JudyL_MD1-Mar-07 2:44
JudyL_MD1-Mar-07 2:44 
GeneralRe: Win Service problem Pin
david bagaturia1-Mar-07 3:11
david bagaturia1-Mar-07 3:11 
GeneralRe: Win Service problem Pin
JudyL_MD1-Mar-07 3:45
JudyL_MD1-Mar-07 3:45 
GeneralRe: Win Service problem Pin
david bagaturia1-Mar-07 18:58
david bagaturia1-Mar-07 18:58 
QuestionAbout Driver priority Pin
mt_samiei28-Feb-07 21:32
mt_samiei28-Feb-07 21:32 
Questionhow can i get all computer in the lan. Pin
bios808628-Feb-07 21:31
bios808628-Feb-07 21:31 
AnswerRe: how can i get all computer in the lan. Pin
bios80861-Mar-07 15:17
bios80861-Mar-07 15:17 
QuestionAbout DirectX??? Pin
siddharthsan28-Feb-07 21:18
siddharthsan28-Feb-07 21:18 
AnswerRe: About DirectX??? Pin
Mark Salsbery1-Mar-07 8:00
Mark Salsbery1-Mar-07 8:00 
QuestionNeed to draw background of edit control Pin
Nishad S28-Feb-07 21:16
Nishad S28-Feb-07 21:16 
AnswerRe: Need to draw background of edit control Pin
baerten28-Feb-07 22:41
baerten28-Feb-07 22:41 
GeneralRe: Need to draw background of edit control Pin
Nishad S28-Feb-07 23:39
Nishad S28-Feb-07 23:39 
AnswerRe: Need to draw background of edit control Pin
Hamid_RT28-Feb-07 23:35
Hamid_RT28-Feb-07 23:35 
Questionnew operator Pin
prithaa28-Feb-07 21:07
prithaa28-Feb-07 21:07 
AnswerRe: new operator Pin
Cedric Moonen28-Feb-07 21:16
Cedric Moonen28-Feb-07 21:16 
GeneralRe: new operator Pin
prithaa28-Feb-07 21:56
prithaa28-Feb-07 21:56 
Questionhow to use SetPrinterDataEx() Pin
mo_nica88128-Feb-07 20:58
mo_nica88128-Feb-07 20:58 

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.