請問如何用編程得到xp某個服務的啟動類型是什麼?是自動,手動,還是已停用?
ServiceControlManager := OpenSCManager(nil, nil, SC_MANAGER_ALL_ACCESS);
ServiceHandle:= OpenService(ServiceControlManager, pchar('Alerter'), SERVICE_CHANGE_CONFIG);
......... //?
...........  //?

解决方案 »

  1.   

    http://borland.mblogger.cn/aiirii/posts/2883.aspx檢索NtService狀態2-檢索指定狀態 
    相關Api:1, QueryServiceConfigThe QueryServiceConfig function retrieves the configuration parameters of the specified service. Optional configuration parameters are available using the QueryServiceConfig2 function.
    BOOL QueryServiceConfig(
      SC_HANDLE hService,
      LPQUERY_SERVICE_CONFIG lpServiceConfig,
      DWORD cbBufSize,
      LPDWORD pcbBytesNeeded
    );2,QueryServiceStatusThe QueryServiceStatus function retrieves the current status of the specified service.This function has been superseded by the QueryServiceStatusEx function. QueryServiceStatusEx returns the same information QueryServiceStatus returns, with the addition of the process identifier and additional information for the service.
    BOOL QueryServiceStatus(
      SC_HANDLE hService,
      LPSERVICE_STATUS lpServiceStatus
    );
      

  2.   

    type
      PENUM_SERVICE_STATUS = ^ENUM_SERVICE_STATUS;
      ENUM_SERVICE_STATUS = packed record
        lpServiceName: PCHAR;
        lpDisplayName: PCHAR;
        ServiceStatus: SERVICE_STATUS;
      end;  PQUERY_SERVICE_CONFIG = ^QUERY_SERVICE_CONFIG;
      QUERY_SERVICE_CONFIG = packed record
        dwServiceType: DWORD;
        dwStartType: DWORD;
        dwErrorControl: DWORD;
        lpBinaryPathName: PCHAR;
        lpLoadOrderGroup: PCHAR;
        dwTagId: DWORD;
        lpDependencies: PCHAR;
        lpServiceStartName: PCHAR;
        lpDisplayName: PCHAR;
      end;implementationfunction EnumServicesStatus(
      const hSCManager: DWORD;
      const dwServiceType: DWORD;
      const dwServiceState: DWORD;
      const lpServices: PENUM_SERVICE_STATUS;
      const cbBufSize: DWORD;
      const pcbBytesNeeded: PDWORD;
      const lpServicesReturned: PDWORD;
      const lpResumeHandle: PDWORD
      ): Longbool; stdcall; external 'advapi32.dll' name 'EnumServicesStatusA';function QueryServiceConfig(
      const hService: DWORD;
      const lpServiceConfig: PQUERY_SERVICE_CONFIG;
      const cbBufSize: DWORD;
      const pcbBytesNeeded: PDWORD
      ): Longbool; stdcall; external 'advapi32.dll' name 'QueryServiceConfigA';