DeleteService删除对应的服务,函数能成功返回,但是重新检查服务列表,被删除的服务还在,只有重新启动系统后才消失,有什么解决办法?

解决方案 »

  1.   

    MSDN 上说的很清楚的:The DeleteService function s a service for deletion from the service control manager database. The database entry is not removed until all open handles to the service have been closed by calls to the CloseServiceHandle function, and the service is not running. A running service is stopped by a call to the ControlService function with the SERVICE_CONTROL_STOP control code. If the service cannot be stopped, the database entry is removed when the system is restarted. The service control manager deletes the service by deleting the service key and its subkeys from the registry. 
      

  2.   

    但是服务如果根本没有启动,是否情况也是一样?必须要 restarted?
      

  3.   

    直接命令行sc delete删除试试,是不是没有来得及刷新.