Proud::INTServiceEvent Class Referenceabstract

Public Member Functions

virtual void Log (int type, const PNTCHAR *text)=0
 
virtual void Run ()=0
 
virtual void Stop ()=0
 
virtual void Pause ()=0
 
virtual void Continue ()=0
 

Detailed Description

Event sink that CNTService needs

This object provides the following functions requested by CNTService. User must realize this class.

  • Server main routine
  • Addtional functions such as function that leaves log

Member Function Documentation

virtual void Proud::INTServiceEvent::Log ( int  type,
const PNTCHAR *  text 
)
pure virtual

Leaves event log

Parameters
typeEither EVENTLOG_ERROR_TYPE or EVENTLOG_WARNING_TYPE or EVENTLOG_INFORMATION_TYPE
textText string to be left
virtual void Proud::INTServiceEvent::Run ( )
pure virtual

Service module main function This function is the main function that is called by service module. Server program main routine must be called to this function. Service is terminated when this function is returned.

Requirements

  • Either a termination by keyboard input or Win32 message process routine must be entered to this function. This is since when service termination order is given by SCM then it recieves WM_QUIT. Please refer the example code shown below.

Reference

  • argc,argv can be acquired from CNTService::Instance(). And other various options can be acquired from CNTService::Instance().

Example source

while(1)
{
Sleep(100);
if(_kbhit())
{
switch(getch())
{
case VK_ESCAPE:
break;
}
}
MSG msg;
// Waits for one of console input, Windows message reception, mina thread termination for max shcedule and short time.
MsgWaitForMultipleObjects(0,0,TRUE,100,QS_ALLEVENTS);
if(PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
{
if(!GetMessage(&msg,NULL,NULL,NULL))
break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}