« links for 2006-04-11 | 回到主頁面 | 2006-04巴里島五日遊 »

April 12, 2006

About the running oder for Window Service


將此網頁加入【百度收藏】... 加入此網頁到【del.icio.us 書籤】 technorati

WindowsService (WinCE).JPG 

We usually doesn't care about the startup odering of Window Services. But there is a situation about this.

You usually don't care what you don't understand.

Total Service: ServiceA and ServiceB.

In ServiceA we will retrieval some information via ServiceB. If ServiceB doesn't start before ServiceA this future will failed. Because all Window Service are controled by SCM ("Service Control Manager).

How do we make sure the startup odering of Window Services?

Actually, SCM dispath all service ramdonly, such that you can not promise the services startup odering. But~~  (mm Here comes a hreo~~ ).

We can set the dependency of every service.

ServiceDependency (Small).JPG 

You can try to open SCM and open a service propertied dialog to see the same information as bellow.

In the table of "Dependency", you will see all depdency services of this service. It will make sure when this service starup all dependency service should already startup. You should set when you create such service.

::CreateService(hSCM,     // SCM pointer
  m_szServiceName,   // service identify name
  m_szServiceName,   // Display service name to display
   SERVICE_ALL_ACCESS,  // desired access
  SERVICE_WIN32_OWN_PROCESS, // service type
  SERVICE_AUTO_START,  // start type
  SERVICE_ERROR_NORMAL,  // error control type
  szFilePath,   // service's binary
  NULL,    // no load ordering group
  NULL,    // no tag identifier
  _T("RPCSS\0"),   // Dependencies on RPC Call Service.
  NULL,    // LocalSystem account
  NULL);    // no password

Please reference MSDN for more detail.



VC6相關問題

由 Evan 發表於 April 12, 2006 將此網頁加入【百度收藏】... 加入此網頁到【del.icio.us 書籤】 technorati
引用
本文的引用網址:


以下是前來引用的連結 'About the running oder for Window Service' 來自 Blog E
迴響
發表迴響









記住我的資訊?




(請輸入以下的驗證碼)