ACE 服务配置器(Service Configurator)

TimeService DLL:

VC6 dll工程属性设置 Setting->C/C++->Category(general)->preprocessor definitions:

WIN32,_DEBUG,_WINDOWS,_MBCS,_USRDLL,TIMESERVICE_EXPORTS,ACE_BUILD_SVC_DLL

-------------------------------------------------------TimeService .h------------------------------------------------------------------

#ifndef TIME_SERVICE_H
#define TIME_SERVICE_H

#include "ace/Service_Config.h"
#include "ace/ace.h"
#include "ace/OS.h"
#include "ace/Task.h"
#include "ace/Synch_T.h"
#include "ace/svc_export.h"

class ACE_Svc_Export TimeService: public ACE_Service_Object
{
 public:
  virtual int init(int argc, char *argv[]);
  virtual int fini(void);
  virtual int suspend(void);
  virtual int resume(void);


 private:

};
ACE_SVC_FACTORY_DECLARE(TimeService)
#endif

-------------------------------------------------------TimeService .cpp------------------------------------------------------------------

#include "TimeService.h"
#include "ace/Log_Msg.h"


int TimeService::init(int argc, char *argv[])
{
    printf("MyDynamicObj::init------/n");
    return 0;
}

int TimeService::fini(void)
{
 printf("TimeService::fini-----/n");
    return 0;
}

//Suspend the Time Service.
int TimeService::suspend(void)
{
 printf("TimeService::fini-----/n");
    return 0;
}

//Resume the Time Service.
int TimeService::resume(void)
{
 printf("TimeService::fini-----/n");
    return 0;
}

ACE_SVC_FACTORY_DEFINE(TimeService)

.................................................................................................................................................................................................

main.cpp

#include "ace/OS.h"
#include "ace/Service_Config.h"
#include "ace/Event_Handler.h"
#include <signal.h>

int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
       ACE_Service_Config::open(argc, argv, ACE_DEFAULT_LOGGER_KEY, 0);
       ACE_Reactor::instance ()->run_reactor_event_loop();
       return 0;
}
..............................................................................................................................................................................................

svc.conf

dynamic TimeService Service_Object * TimeService:_make_TimeService() ""

阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页