Using C + + Windows services for the preparation of the general framework

  Below are the Service, I wrote a procedural framework to achieve the following functions: 

  1.    Service surveillance window created. 

  2.    Message Handling Service in the realization of 

   3.      C + + class use.  

   4.      Work function of the use of threads.  

  **** If you need to complete specific tasks, simply threading function and specific examples of ***. 

  (Note that the procedures used in Japanese writing, because I machinery OS is a Japanese WIN 2000, VC is also Japanese VC6.0 can not support Chinese, sorry) 

  / * 

  Japanese payバーjinnョンformer contents 

  20040706 1.00 SecBug new regulations make 
  * / 

  Class MyServiceModel 
  ( 
  Public: 
  MyServiceModel (); 
  Virtual ~ MyServiceModel (); 

  Private: 

  / / Alter a few 

  / / Moses Arabic nameス 
  LPCTSTR serviceName; 
  / / Moses Arabicスwho maintain their state of things! 
  SERVICE_STATUS serviceStatus; 
  / / Private Moses Arabicスtheir AL-HaンAd 
  SERVICE_STATUS_HANDLE serviceStatusHandle; 

  HWND hCMain_seivice_data; 

  //————— Private ———– 
  / / Event used to hold ServiceMain from completing 
  HANDLE terminateEvent; 
  / / Thread for the actual work 
  HANDLE threadHandle; 
  / / Flags holding current state of service 
  BOOL pauseService; 
  BOOL runningService; 

  / /メソAllah Ad 

  Public: 

  / /メインメソAllah Ad: 
  Int main (int argc, TCHAR * argv []); 
  / / Moses ArabicスインスLot the Criterion: 
  Void InstallService (); 
  / / Moses Arabicス- AnインスLot the Criterion: 
  Void UninstallService (); 
  / / Moses Arabicスメイン: 
  Void WINAPI ServiceMain (DWORD argc, TCHAR * argv []); 
  / / Moses ArabicスperfectedンLot mouths the Criterion HaンAd Allah: 
  Void WINAPI ServiceControlHandler (DWORD contorlCode); 
  / / Pharaoh Pharaohインtribe. However mouths treesーjinnャ: 
  LRESULT CALLBACK WndProc (HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam); 
  //————— Private ———– 

  / / Pharaoh Pharaohインtribe. However mouths treesーjinnャ 
  Static LRESULT CALLBACK _WndProc ( 
  HWND hDlg, 
  UINT Msg, 
  WPARAM wParam, 
  LPARAM lParam 
);
  / / Moses ArabicスperfectedンLot mouths the Criterion HaンAd Allah 
  Static void WINAPI _ServiceControlHandler (DWORD contorlCode); 
  / / Moses Arabicスメイン 
  Static void WINAPI _ServiceMain (DWORD argc, TCHAR * argv []); 
  BOOL CreateSvcWindow (); 
  / / Allah deal with Israel 
  Void ErrorHandler (char * s, DWORD err); 
  / / Moses Arabicスthings ended! 
  VOID terminate (DWORD error); 
  / /スSeteーconcertスreport things! 
  BOOL SendStatusToSCM ( 
  DWORD dwCurrentState, 
  DWORD dwWin32ExitCode, 
  DWORD dwServiceSpecificExitCode, 
  DWORD dwCheckPoint, 
  DWORD dwWaitHint 
);
  / / End of Moses in Arabicス 
  VOID StopService (); 
  / / Beginning of Moses in Arabicス 
  BOOL InitService (); 
  / / Browser jinnメMoses Arabicス 
  VOID ResumeService (); 
  / /ポーThul Moses Arabicス 
  VOID PauseService (); 
  / / 
  BOOL RunService (char * sSvcName); 
  ); 
  / /スbroadcasts Commissioner of Allah Ad 
  DWORD WINAPI ServiceThread (LPDWORD param); 

  / * 
  Japanese payバーjinnョンformer contents 

  20040706 1.00 SecBug new regulations make 

  * / 

  / / Declaration of a Change 
  Extern MyServiceModel objApp; 

  ////////////////////////////////////////////////// //////////////////// 
  / / Build / eradication 
  ////////////////////////////////////////////////// //////////////////// 

  / * 
  Build function 
  Static 
  Public visibility 
 ãƒ¡ã‚½Allah tribe were MyServiceModel 
  Reply few 
  Notし 
  Back than you valueし 
  * / 
  MyServiceModel:: MyServiceModel () 
  ( 
  / / Moses Arabic nameス 
  ServiceName = "MyServiceName"; 
  / / Moses Arabicスwho maintain their state of things! 
  ServiceStatusHandle = NULL; 
  ) 

  / * 
  Function eradication 
  Static 
  Public visibility 
 ãƒ¡ã‚½Allah tribe were to MyServiceModel 
  Reply few 
  Notし 
  Back than you valueし 
  * / 
  MyServiceModel:: ~ MyServiceModel () 
  ( 

  ) 

  / * 

  FunctionメインメソAllah Ad 
  Static 
  Public visibility 
 ãƒ¡ã‚½whom were main Ad 
  Reply few 
  Reply of their number [IN] argc int initial value notし 
  Reply of the [IN] [] * argv TCHAR initial value notし 
  Back than value 
  Int often Lo 0 
  Note 
  Notし 

  * / 
  Int MyServiceModel:: main (int argc, TCHAR * argv []) 
  ( 
  Int iRet = 0; 

  TCHAR TServceName [256]; 
  Strcpy (TServceName, SVCSTARTNAME); 

  SERVICE_TABLE_ENTRY dispatchTable [] = 
  ( 
  (TEXT (TServceName), (LPSERVICE_MAIN_FUNCTION) _ServiceMain), 
  (NULL, NULL) 

  ); 

  / / Reply of their defeatedã‚§Allah Talk: 
  If (argc <= 1) 
  ( 
  / / GrapesランTalk is their occasions, usage (use) 
  Cout << "usage:" <<ENDL; 
  / / Cout << "zxz \" zxz "<<ENDL; 
  / / "Install" 
  Cout << "\" install \ ""; 
  / / "Or" 
  Cout << "or"; 
  / / "Uninstall" 
  Cout << "\" uninstall \ ""; 
  / / The "exec" 
  Cout << "\" exec \ ""; 
  Cout << "parameter required in the command line" <<ENDL;? 

  ) 

  / / Install their occasions, Moses Arabicスtheir login wrong-doers (InstallService breath) 
  If (argc> 1) 
  ( 
  If (_stricmp ( "install", argv [1]) == 0) 
  ( 
  InstallService (); 
  ) 
  / / Uninstall their occasions, Moses Arabicスtheir trimmed away wrong-doers (UninstallService breath) 
  Else if (_stricmp ( "uninstall", argv [1]) == 0) 
  ( 
  UninstallService (); 
  ) 

  / / Exec their occasions, Moses Arabicスstarting their wrong-doers (ServiceMain breath) 
  Else if (_stricmp ( "exec", argv [1]) == 0) 
  ( 
  RunService (SVCSTARTNAME); 

  ) 

  / / GrapesランTalk is their occasions, usage (use) 
  Else 
  ( 
  Cout << "usage:" <<ENDL; 
  / / "Install" 
  Cout << "\" install \ ""; 
  / / "Or" 
  Cout << "or"; 
  / / "Uninstall" 
  Cout << "\" uninstall \ ""; 
  / / The "exec" 
  Cout << "\" exec \ ""; 
  / / "Or" 
  Cout << "or"; 
  Cout << "parameter required in the command line" <<ENDL; 
  ) 
  ) 
  / / Lecture their grapesランoccasions, Moses Arabicスstarting their wrong-doers (RunService breath) 
  Else 
  ( 

  / / RunService exhaled 
  BOOL success; 
  StartServiceCtrlDispatcher success = (dispatchTable); 
  If (success) 
  ( 
  ErrorHandler ( "In StartServiceCtrlDispatcher", GetLastError ()); 
  ) 

  ) 

  / / Value back than regular Lo 0 
  IRet = 0; 

  Return iRet; 

  ) 

  / * 
  Function Moses ArabicスインスLot the Criterion 
  Static 
  Public visibility 
 ãƒ¡ã‚½Allah tribe were InstallService 
  Reply few 
  Notし 
  Back than value 
  Notし 
  Note 
  Moses ArabicスtheirインスLot the Criterion wrong-doers 
  * / 
  Void MyServiceModel:: InstallService () 
  ( 
  SC_HANDLE schService; 
  SC_HANDLE schSCManager; 
  TCHAR szPath [512]; 

  Cout << "Install Starting …"<< ENDL; 

  / /フmaterialイAl Hornースおthings were! 
  If (! GetModuleFileName (NULL, szPath, 512)) 
  ( 
  ErrorHandler ( "In GetModuleFileName", GetLastError ()); 
  Return; 

  ) 

  / / Open perfectedネTalk treesョンto SCM 
  SchSCManager = OpenSCManager ( 
  0, / / pointer to machine name string 
  0, / / pointer to database name string 
  SC_MANAGER_CREATE_SERVICE / / type of access 
);
  If (! SchSCManager) 
  ( 
  ErrorHandler ( "In OpenScManager", GetLastError ()); 
  Return; 
  ) 
  / / Install new Moses Arabicス 
  CreateService schService = ( 
  SchSCManager, / / handle to service control manager database 
  SVCSTARTNAME, / / pointer to name of service to start 
  SVCDISPLNAME, / / pointer to display name 
  SERVICE_ALL_ACCESS, / / type of access to service 
  SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS, / / type of service 
  SERVICE_DEMAND_START, / / when to start service 
  SERVICE_ERROR_NORMAL, / / severity if service fails to start 
  SzPath, / / pointer to name of binary file 
  NULL, / / pointer to name of load ordering group 
  NULL, / / pointer to variable to get tag identifier 
  NULL, / / pointer to array of dependency names 
  NULL, / / pointer to account name of service 
  NULL / / pointer to password for service account 
);
  If (! SchService) 
  ( 
  ErrorHandler ( "In CreateService", GetLastError ()); 
  Return; 
  ) 
  Else 
  ( 
  Cout << "Service installed \ n"; 
  ) 

  / / Clean up 
  CloseServiceHandle (schService); 
  CloseServiceHandle (schSCManager); 

  Cout << "Install Ending … \ n"; 

  ) 

  / * 
  Function Moses - An ArabicスtheirインスLot the Criterion 
  Static 
  Public visibility 
 ãƒ¡ã‚½Allah tribe were UninstallService 
  Reply few 
  Notし 
  Back than value 
  Notし 
  Note 
  Moses - An ArabicスtheirインスLot the Criterion wrong-doers 
  * / 
  Void MyServiceModel:: UninstallService () 
  ( 

  SC_HANDLE schService; 
  SC_HANDLE schSCManager; 
  BOOL success; 
  SERVICE_STATUS svcStatus; 

  Cout << "Uninstall Starting …"<< ENDL;? 

  / / Open perfectedネTalk treesョンto SCM 
  SchSCManager = OpenSCManager ( 
  0, / / pointer to machine name string 
  0, / / pointer to database name string 
  SC_MANAGER_CREATE_SERVICE / / type of access 
);
  If (! SchSCManager) 
  ( 
  ErrorHandler ( "In OpenScManager", GetLastError ()); 
  Return; 
  ) 

  / / Moses ArabicスHa!ンSad Al-access things 
  SchService = OpenService ( 
  SchSCManager, / / handle to service control manager database 
  SVCSTARTNAME, / / pointer to name of service to start 
  SERVICE_ALL_ACCESS | DELETE / / type of access to service 
);
  If (! SchService) 
  ( 
  ErrorHandler ( "In OpenService", GetLastError ()); 
  Return; 
  ) 

  / / Moses Arabicスend (if necessary) 
  QueryServiceStatus success = (schService, & svcStatus); 
  If (! Success) 
  ( 
  ErrorHandler ( "In QueryServiceStatus", GetLastError ()); 
  Return; 
  ) 
  If (svcStatus.dwCurrentState! = SERVICE_STOPPED) 
  ( 
  Cout << "Stopping service …"<< ENDL; 
  ControlService success = ( 
  SchService, / / handle to service 
  SERVICE_CONTROL_STOP, / / control code 
  & SvcStatus / / pointer to service status structure 
);
  If (! Success) 
  ( 
  ErrorHandler ( "In ControlService", GetLastError ()); 
  Return; 
  ) 

  ) 

  / / Moses Arabicスsign that the end of Able 
  Do 
  ( 
  QueryServiceStatus (schService, & svcStatus); 
  Sleep (500); 

  ) While (SERVICE_STOP_PENDING == svcStatus.dwCurrentState); 

  If (SERVICE_STOPPED! = SvcStatus.dwCurrentState) 
  ( 
  ErrorHandler ( "Failed to Stop Service", GetLastError ()); 
  Return; 
  ) 

  / / Moses Arabicスthings trimmed away! 
  DeleteService success = (schService); 
  If (success) 
  ( 
  Cout << "Service removed \ n"; 
  ) 
  Else 
  ( 
  ErrorHandler ( "In DeleteService", GetLastError ()); 
  Return; 
  ) 

  / / Moses ArabicスClean up 
  CloseServiceHandle (schService); 
  CloseServiceHandle (schSCManager); 

  Cout << "Uninstal Ending …"<< ENDL;? 
  ) 

  / * 
  Function Moses Arabicスメイン 
  Static 
  Public visibility 
 ãƒ¡ã‚½Allah tribe were ServiceMain 
  Reply few 
  Reply of their number [IN] argc DWORD notし 
  Reply of the [IN] [] * argv TCHAR notし 

  Back than value 
  Notし 
  Note 
  DamascoンLot mouths the Criterion Hornネremember Moses in Arabic. HoweverスAllah commandedケーtreesョンwho opened him, Moses Arabicスhave chosen Ze and do [start] Allah who commanded Talk Talkしwhen you Lo, from SCM summon slain. 
  Moses Arabicスtheirメインdeal with wrong-doers: 
  * / 
  Void WINAPI MyServiceModel:: ServiceMain (DWORD argc, TCHAR * argv []) 
  ( 

  BOOL success; 

  / / SCM Lo HaンAdラCommissioner few who cross! 
  RegisterServiceCtrlHandler serviceStatusHandle = ( 
SVCSTARTNAME,
  (LPHANDLER_FUNCTION) _ServiceControlHandler 
);
  If (! ServiceStatusHandle) 
  ( 
  Terminate (GetLastError ()); 
  Return; 
  ) 

  / / Moses Arabicスstate who started things Lo! 
  SendStatusToSCM success = ( 
SERVICE_START_PENDING,
NO_ERROR,
0,
  1. 
5000
);
  If (! Success) 
  ( 
  Terminate (GetLastError ()); 
  Return; 
  ) 

  / / EndイservantsンLot create things! 
  CreateEvent terminateEvent = ( 
0,
TRUE,
FALSE,
0
);
  If (! TerminateEvent) 
  ( 
  Terminate (GetLastError ()); 
  Return; 
  ) 

  / / SCM things briefing! 
  SendStatusToSCM success = ( 
SERVICE_START_PENDING,
NO_ERROR,
0,
  2. 
1000
);
  If (! Success) 
  ( 
  Terminate (GetLastError ()); 
  Return; 
  ) 

  / / Early Arabicスof Moses, 
  / /メAllah Centerーphoto ID who made deeds, and to alter the numberお 
  / / Ad Pharaoh Pharaohインmake their 
  InitService success = (); 
  If (! Success) 
  ( 
  Terminate (GetLastError ()); 
  Return; 
  ) 

  / / Moses Arabicスtruth trip. 
  / / SCM things briefing! 
  SendStatusToSCM success = ( 
SERVICE_RUNNING,
NO_ERROR,
0,
0,
0
);
  If (! Success) 
  ( 
  Terminate (GetLastError ()); 
  Return; 
  ) 

  / / Moses in Arabic to stop us theirス 
  WaitForSingleObject (terminateEvent, INFINITE); 

  / / Moses Arabic Loスstate who stop and the earth. 
  Terminate (0); 

  ) 

  / * 
  Function Moses ArabicスperfectedンLot mouths the Criterion HaンAd Allah 
  Static 
  Public visibility 
 ãƒ¡ã‚½Allah tribe were ServiceControlHandler 
  Reply few 
  State perfected the tribe [IN] contorlCode DWORD notし 
  Back than value 
  Notし 
  Note 
  "SCM when Moses ArabicスtheirスSeteーwho in concertスthan you, you stop soon stop whatever 1:00 of the command who Moses ArabicスLo things not for the delivery from SCM summon slain. 
  SCM is Handler Lo, the truth will speak of their treatment table! Types who deal with the tribe who Damasco crossingしme. 
  1. Moses Arabicスstop to notice when you occasions, Moses Arabic Loスstop a Change 
  2. Stop dealing with wrong-doers (ServiceMain Lo who stop notice) 
  3. Their occasions And he is not what Had 

  * / 
  Void WINAPI MyServiceModel:: ServiceControlHandler (DWORD contorlCode) 
  ( 
  DWORD currentState = 0; 
  BOOL success; 

  Switch (contorlCode) 
  ( 
  / / There is no START option because 
  / / ServiceMain gets called on a start 

  / / Moses Arabicスthings ended! 
  Case SERVICE_CONTROL_STOP: 
  CurrentState = SERVICE_STOP_PENDING; 
  / / Tell the SCM what's happening 
  SendStatusToSCM success = ( 
SERVICE_STOP_PENDING,
NO_ERROR,
0,
  1. 
5000
);
  / / Not much to do if not successful 
  / / Stop the service 
  StopService (); 
  Return; 

  / / Moses ArabicスポーThul 
  Case SERVICE_CONTROL_PAUSE: 
  If (runningService & &! PauseService) 
  ( 
  / / Tell the SCM what's happening 
  SendStatusToSCM success = ( 
SERVICE_PAUSE_PENDING,
NO_ERROR,
0,
  1. 
1000);
  PauseService (); 
  CurrentState = SERVICE_PAUSED; 
  ) 
  Break; 

  / / Moses Arabicスonly for those men again 
  Case SERVICE_CONTROL_CONTINUE: 
  If (runningService & pauseService) 
  ( 
  / / Tell the SCM what's happening 
  SendStatusToSCM success = ( 
SERVICE_CONTINUE_PENDING,
NO_ERROR,
0,
  1. 
1000
);
  ResumeService (); 
  CurrentState = SERVICE_RUNNING; 
  ) 
  Break; 

  / / Moses Arabicスtheir present theirスSeteーconcertスupdate 
  Case SERVICE_CONTROL_INTERROGATE: 
  / / It will fall to bottom and send status 
  Break; 

  / / Do nothing in a shutdown. Could do cleanup 
  / / Here but it must be very quick. 
  Case SERVICE_CONTROL_SHUTDOWN: 
  / / Do nothing on shutdown 
  Return; 
  Default: 
  Break; 
  ) 

  / / Moses Arabicスtheir present theirスSeteーconcertスupdate 
  SendStatusToSCM ( 
  CurrentState, 
NO_ERROR,
0,
0,
0
);

  ) 

  / * 
  Adインfunction Pharaoh Pharaoh. However mouths treesーjinnャ 
  Static 
  Public visibility 
 ãƒ¡ã‚½Allah tribe of WndProc 
  Reply few 
  Pharaoh PharaohインSad Sad HaンAL-[IN] hDlg HWND notし 
 ãƒ¡Allah Centerーjinn [IN] Msg UINT notし 
  Hornラメconcert 1 [IN] wParam WPARAM notし 
  Hornラメconcert 2 [IN] lParam LPARAM notし 
  Back than value 
LRESULT
  Note 
  "Pharaoh PharaohインAdメAllah Centerーjinn their analytical processing wrong-doers 
  * / 
  LRESULT CALLBACK MyServiceModel:: WndProc (HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam) 
  (LRESULT lrRet; 

  / * 

  / / Test begin 

  HDC hdc; 
  PAINTSTRUCT ps; 
  Int x, y; 

  X = 60; 
  Y = 20; 

  Test end 
  * / 

  Switch (Msg) 
  ( 
  Case WM_DESTROY: 
  PostQuitMessage (0); 
  Break; 

  ); 

  / / And heメAllah Centerーtheir photo is their occasions, DefWindowProc who exhaled " 
  LrRet = DefWindowProc (hDlg, Msg, wParam, lParam); 

  Return lrRet; 
  ) 

  / * 

  Israel Allah processing function 
  Static 
  Visibility private 
 ãƒ¡ã‚½Allah tribe were ErrorHandler 
  Reply few 
  Hornラメconcert 1 [IN] char * s notし 
  Hornラメconcert 2 [IN] DWORD err notし 
  Back than value 
  Notし 
  Note 
  Notし 
  * / 
  Void MyServiceModel:: ErrorHandler (char * s, DWORD err) 
  ( 
  Cout <<S <<ENDL; 
  Cout << "Error number:" <<err <<endl; 

  Char str1 [50]; 
  Char str2 [20]; 

  Memset (str1, 0, sizeof (str1)); 
  Memset (str2, 0, sizeof (str2)); 

  Strcpy (str1, s); 

  Strcat (str1, "Error Code:"); 
  Itoa (err, str2, 10); 
  Strcat (str1, str2); 

  ExitProcess (err); 

  ) 

  / * 
  Function Moses Arabicスthings ended! 
  Static 
  Visibility private 
 ãƒ¡ã‚½Allah who terminate Ad 
  Reply few 
  Hornラメconcert DWORD error notし 
  Back than value 
  Notし 
  Note 
  Moses Arabicスthings ended! 

  * / 
  VOID MyServiceModel:: terminate (DWORD error) 
  ( 
  / / If terminateEvent has been created, and close it. 
  If (terminateEvent) 
  CloseHandle (terminateEvent); 

  / / Send a message to the scm to tell about 
  / / Stopage 
  If (serviceStatusHandle) 
  SendStatusToSCM (SERVICE_STOPPED, error, 
  0, 0, 0); 

  / / If the thread has started kill it off 
  If (threadHandle) 
  CloseHandle (threadHandle); 

  / / Do not need to close serviceStatusHandle 
  ) 

  / * 
  FunctionスSeteーconcertスreport things! 
  Static 
  Visibility private 
 ãƒ¡ã‚½of Allah Ad 
  Reply few 
  Hornラメconcert a DWORD dwCurrentState, 
  Hornラメconcert 2 DWORD dwWin32ExitCode, 
  Hornラメconcert DWORD dwServiceSpecificExitCode 3, 
  Hornラメconcert DWORD dwCheckPoint 4, 
  Hornラメconcert 5 DWORD dwWaitHint 
  Back than value 
  Notし 
  Note 
  Consolidates the activities of updating the service status with SetServiceStatus 
  * / 
  BOOL MyServiceModel:: SendStatusToSCM (DWORD dwCurrentState, 
  DWORD dwWin32ExitCode, 
  DWORD dwServiceSpecificExitCode, 
  DWORD dwCheckPoint, 
  DWORD dwWaitHint) 
  ( 
  BOOL success; 
  SERVICE_STATUS serviceStatus; 

  / / Fill in all of the SERVICE_STATUS fields 
  ServiceStatus.dwServiceType = 
SERVICE_WIN32_OWN_PROCESS;
  ServiceStatus.dwCurrentState = dwCurrentState; 

  / / If in the process of something, then accept 
  / / No control events, else accept anything 
  If (dwCurrentState == SERVICE_START_PENDING) 
  ServiceStatus.dwControlsAccepted = 0; 
  Else 
  ServiceStatus.dwControlsAccepted = 
  SERVICE_ACCEPT_STOP | 
  SERVICE_ACCEPT_PAUSE_CONTINUE | 
SERVICE_ACCEPT_SHUTDOWN;

  / / If a specific exit code is defines, set up 
  / / The win32 exit code properly 
  If (dwServiceSpecificExitCode == 0) 
  ServiceStatus.dwWin32ExitCode = 
  DwWin32ExitCode; 
  Else 
  ServiceStatus.dwWin32ExitCode = 
ERROR_SERVICE_SPECIFIC_ERROR;
  ServiceStatus.dwServiceSpecificExitCode = 
  DwServiceSpecificExitCode; 

  ServiceStatus.dwCheckPoint = dwCheckPoint; 
  ServiceStatus.dwWaitHint = dwWaitHint; 

  / / Pass the status record to the SCM 
  SetServiceStatus success = (serviceStatusHandle, 
  & ServiceStatus); 
  If (! Success) 
  StopService (); 

  Return success; 
  ) 

  / * 
  Moses function of early Arabicス 
  Static 
  Visibility private 
 ãƒ¡ã‚½Allah tribe were InitService 
  Reply few 
  Notし 
  Back than value 
  Notし 
  Note 
  Initializes the service by starting its thread 

  * / 
  BOOL MyServiceModel:: InitService () 
  ( 
  DWORD id; 

  / / Start the service's thread 
  ThreadHandle = CreateThread (0, 0, 
  (LPTHREAD_START_ROUTINE) ServiceThread, 
  0, 0, & id); 

  If (threadHandle == 0) 
  Return FALSE; 
  Else 
  ( 
  RunningService = TRUE; 
  Return TRUE; 
  ) 
  ) 

  / * 
  Start function Moses Arabicス 
  Static 
  Visibility private 
 ãƒ¡ã‚½Allah tribe were StartService 
  Reply few 
  SSvcName: Moses Arabic nameス 
  Back than value 
  Notし 
  Note 
  Resumes a paused service 
  * / 

  BOOL MyServiceModel:: RunService (char * sSvcName) 
  ( 

  SC_HANDLE schSCManager; 
  SC_HANDLE scHandle; 
  BOOL boolRet; 

  / / Open perfectedネTalk treesョンto SCM 
  SchSCManager = OpenSCManager ( 
0,
0,
SC_MANAGER_ALL_ACCESS
);

  / / Open Moses Arabicス 
  ScHandle = OpenService ( 
  SchSCManager, 
  SSvcName, 
SERVICE_ALL_ACCESS
);

  / / Start Moses Arabicス 
  StartService boolRet = ( 
  ScHandle, 
0,
NULL);

  Return boolRet; 
  ) 

  / * 
  Function broadcasts jinnメMoses Arabicス 
  Static 
  Visibility private 
 ãƒ¡ã‚½Allah tribe were ResumeService 
  Reply few 
  Notし 
  Back than value 
  Notし 
  Note 
  Resumes a paused service 
  * / 
  VOID MyServiceModel:: ResumeService () 
  ( 
  / / PauseService = FALSE; 
  / / ResumeThread (threadHandle); 
  Return; 
  ) 

  / * 
  FunctionポーThul Moses Arabicス 
  Static 
  Visibility private 
 ãƒ¡ã‚½Allah tribe were PauseService 
  Reply few 
  Notし 
  Back than value 
  Notし 
  Note 
  Pauses the service 
  * / 
  VOID MyServiceModel:: PauseService () 
  ( 
  / / PauseService = TRUE; 
  / / SuspendThread (threadHandle); 
  Return; 
  ) 

  / * 
  Function ended Moses Arabicス 
  Static 
  Visibility private 
 ãƒ¡ã‚½of Allah Ad 
  Reply few 
  Hornラメconcert notし 
  Back than value 
  Notし 
  Note 
  Stops the service by allowing ServiceMain to complete 
  * / 

  VOID MyServiceModel:: StopService () 
  ( 
  RunningService = FALSE; 
  / / Set the event that is holding ServiceMain 
  / / So that ServiceMain can return 
  SetEvent (terminateEvent); 
  ) 

  / * 
  Allah Adスbrowser function of the Commissioner 
  Static 
  Visibility private 
 ãƒ¡ã‚½Allah tribe were ServiceThread 
  Reply few 
  Hornラメconcert LPDWORD param 
  Back than value 
0
  Note 
  Notし 
  * / 
  DWORD WINAPI ServiceThread (LPDWORD param) 
  ( 
  / / Ad Pharaoh Pharaohインmake their 
  ObjApp.CreateSvcWindow (); 
  Return 0; 
  ) 

  / * 
  Adインfunction Pharaoh Pharaoh make their 
  Static 
  Visibility private 
 ãƒ¡ã‚½Allah tribe were CreateSvcWindow 
  Reply few 
  Hornラメconcert notし 
  Back than value 
  Notし 
  Note 
  Notし 
  * / 
  BOOL MyServiceModel:: CreateSvcWindow () 
  ( 
  / / Ad Pharaoh Pharaohインmake their 
  / / The handle of the windows 
  HWND hwnd; 
  / / The struct of the WNDCALSS 
  WNDCLASS wc; 
  MSG msg; 

  HINSTANCE hInstance = (HINSTANCE):: GetModuleHandle (NULL); 

  Wc.style = CS_VREDRAW | CS_HREDRAW; 
  Wc.lpfnWndProc = (WNDPROC) (_WndProc); 
  Wc.cbClsExtra = 0; 
  Wc.cbWndExtra = 0; 
  Wc.hInstance = hInstance; 
  Wc.hIcon = LoadIcon (hInstance, IDI_APPLICATION); 
  Wc.hCursor = LoadCursor (NULL, IDC_ARROW); 
  Wc.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH); 
  Wc.lpszMenuName = NULL; 
  Wc.lpszClassName = "PDFMainSvcWindow"; 

  / / Register the windows class 
  ATOM aaa = RegisterClass (& wc); 
  If (aaa == 0) 
  ( 
  Cout << "RegisterClass Error:" <<GETLASTERROR () <<ENDL; 
  ) 

  / / Ad Pharaoh Pharaohインmake their 
  Hwnd = CreateWindow ( 
  "PDFMainSvcWindow" 
  "メインMoses ArabicインAdスPharaoh Pharaoh" 
WS_OVERLAPPEDWINDOW,
  CW_USEDEFAULT, 
  CW_USEDEFAULT, 
  CW_USEDEFAULT, 
  CW_USEDEFAULT, 
NULL,
NULL,
  HInstance, 
NULL
);

  If (! Hwnd) 
  Return FALSE; 

  ShowWindow (hwnd, SW_SHOWNORMAL); 
  UpdateWindow (hwnd); 

  HCMain_seivice_data = hwnd; 

  / / Back to their first concert whoイSolomon was set and the earth. 
  SetTimer (hwnd, TIMER_SYS_ID, TIMER_ELAPSE_VALUE, NULL); 

  / /メAllah Centerーjinn folk of their start. However, 
  While (GetMessage (& msg, NULL, 0, 0)) 
  ( 
  TranslateMessage (& msg); 
  DispatchMessage (& msg); 
  ) 

  / / While (1) (); 
  Return FALSE; 

  ) 

  / * 
  Function Moses Arabicスメイン 
  Static 
  Public visibility 
 ãƒ¡ã‚½Allah tribe were ServiceMain 
  Reply few 
  Reply of their number [IN] argc DWORD notし 
  Reply of the [IN] [] * argv TCHAR notし 

  Back than value 
  Notし 
  Note 
  DamascoンLot mouths the Criterion Hornネremember Moses in Arabic. HoweverスAllah commandedケーtreesョンwho opened him, Moses Arabicスhave chosen Ze and do [start] Allah who commanded Talk Talkしwhen you Lo, from SCM summon slain. 
  Moses Arabicスtheirメインdeal with wrong-doers: 
  * / 
  Void WINAPI MyServiceModel:: _ServiceMain (DWORD argc, TCHAR * argv []) 
  ( 
  ObjApp.ServiceMain (argc, argv); 
  ) 

  / * 

  Function Moses ArabicスperfectedンLot mouths the Criterion HaンAd Allah 
  Static 
  Public visibility 
 ãƒ¡ã‚½Allah tribe were ServiceControlHandler 
  Reply few 
  State perfected the tribe [IN] contorlCode DWORD notし 
  Back than value 
  Notし 
  Note 
  "SCM when Moses ArabicスtheirスSeteーwho in concertスthan you, you stop soon stop whatever 1:00 of the command who Moses ArabicスLo things not for the delivery from SCM summon slain. 
  SCM is Handler Lo, the truth will speak of their treatment table! Types who deal with the tribe who Damasco crossingしme. 
  1. Moses Arabicスstop to notice when you occasions, Moses Arabic Loスstop a Change 
  2. Stop dealing with wrong-doers (ServiceMain Lo who stop notice) 
  3. Their occasions And he is not what Had " 
  * / 

  Void WINAPI MyServiceModel:: _ServiceControlHandler (DWORD contorlCode) 
  ( 
  ObjApp.ServiceControlHandler (contorlCode); 
  ) 

  / * 
  Adインfunction Pharaoh Pharaoh. However mouths treesーjinnャ 
  Static 
  Public visibility 
 ãƒ¡ã‚½Allah tribe of WndProc 
  Reply few 
  Pharaoh PharaohインSad Sad HaンAL-[IN] hDlg HWND notし 
 ãƒ¡Allah Centerーjinn [IN] Msg UINT notし 
  Hornラメconcert 1 [IN] wParam WPARAM notし 
  Hornラメconcert 2 [IN] lParam LPARAM notし 
  Back than value 
LRESULT
  Note 
  "Pharaoh PharaohインAdメAllah Centerーjinn their analytical processing wrong-doers 
  * / 
  LRESULT CALLBACK MyServiceModel:: _WndProc (HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam) 
  ( 
  Return objApp.WndProc (hDlg, Msg, wParam, lParam); 
  ) 

Bookmark it: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Google
  • DotNetKicks
  • DZone
  • Furl
  • Netvouz

Tags: ,

Releated Articles


0 Comments to “Using C + + Windows services for the preparation of the general framework”

No Comments. Send your comment.

Leave a Reply

You must be logged in to post a comment.