00001 #ifdef _SERVICE
00002 extern "C" uint32 _StartService();
00003 extern "C" uint32 _StopService();
00004 #else
00005 extern "C" uint32 _StartApp();
00006 #endif
00007
00008 #ifndef _SERVICE
00009
00010
00011
00012 #define STARTAPP(x,y) \
00013 uint32 _StartApp() { \
00014 x *MainInstance; \
00015 MainInstance = new x; \
00016 MainInstance->ThreadHandle=SystemCode::GetCurrentThreadHandle(); \
00017 MainInstance->ThreadID=SystemCode::GetCurrentThreadId(); \
00018 MainInstance->ThreadMainParam = y; \
00019 SystemData->MainThread = MainInstance; \
00020 return MainInstance->__StartThread(); \
00021 }
00022
00023 #else //_SERVICE
00024
00025
00026 #define STARTAPP(x,y) \
00027 DefineThreadManager(Win32ServiceThreadMgrClass,x,Win32ServiceThreadMgr); \
00028 uint32 _StartService() { \
00029 SystemData->MainThread=Win32ServiceThreadMgr.CreateThread(y); \
00030 SystemCode::StartThread(SystemData->MainThread); \
00031 SystemCode::SetServiceStatus(TRUE); \
00032 return 0; \
00033 } \
00034 uint32 _StopService() { \
00035 SystemCode::PostMessage(SystemData->MainThread,MSG_EXIT,0,0); \
00036 while (SystemCode::IsThreadActive(SystemData->MainThread)) SystemCode::Sleep(10); \
00037 SystemCode::SetServiceStatus(FALSE); \
00038 return 0; \
00039 }
00040
00041 #endif //_SERVICE
00042