如何把一个exe程序注册为windowsnt\2000服务,启动时将其运行

解决方案 »

  1.   

    CreateService
    The CreateService function creates a service object and adds it to the specified service control manager database. SC_HANDLE CreateService(
      SC_HANDLE hSCManager,  // handle to service control manager 
                             // database
      LPCTSTR lpServiceName, // pointer to name of service to start
      LPCTSTR lpDisplayName, // pointer to display name
      DWORD dwDesiredAccess, // type of access to service
      DWORD dwServiceType,   // type of service
      DWORD dwStartType,     // when to start service
      DWORD dwErrorControl,  // severity if service fails to start
      LPCTSTR lpBinaryPathName,  // pointer to name of binary file
      LPCTSTR lpLoadOrderGroup,  // pointer to name of load ordering 
                                 // group
      LPDWORD lpdwTagId,     // pointer to variable to get tag identifier
      LPCTSTR lpDependencies,  // pointer to array of dependency names
      LPCTSTR lpServiceStartName,
                               // pointer to account name of service
      LPCTSTR lpPassword       // pointer to password for service account
    );
     
      

  2.   

    关键是要运行的exe程序文件有什么要求嘛?
    我用SrvInstw.exe已经把程序注册为服务了,但是这个服务启动不起来,总出错