DeleteService删除服务的小问题

PC_9527 2011-11-23 08:49:15
DeleteService删除对应的服务,函数能成功返回,但是重新检查服务列表,被删除的服务还在,只有重新启动系统后才消失,有什么解决办法?
...全文
835 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
PC_9527 2011-12-01
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 oyljerry 的回复:]
引用 7 楼 pc_9527 的回复:
引用 5 楼 oyljerry 的回复:
直接命令行sc delete删除试试,是不是没有来得及刷新.


退出程序后就生效了,是不是打开的句柄没有关闭?

你CloseHandle关闭对应的句柄
[/Quote]
嗯,再检查一下
oyljerry 2011-12-01
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 pc_9527 的回复:]
引用 5 楼 oyljerry 的回复:
直接命令行sc delete删除试试,是不是没有来得及刷新.


退出程序后就生效了,是不是打开的句柄没有关闭?
[/Quote]
你CloseHandle关闭对应的句柄
PC_9527 2011-12-01
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 oyljerry 的回复:]
直接命令行sc delete删除试试,是不是没有来得及刷新.
[/Quote]

退出程序后就生效了,是不是打开的句柄没有关闭?
Gloveing 2011-11-26
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 oyljerry 的回复:]

直接命令行sc delete删除试试,是不是没有来得及刷新.
[/Quote]
++
可能不会立即更新,自己刷新一下?
oyljerry 2011-11-26
  • 打赏
  • 举报
回复
直接命令行sc delete删除试试,是不是没有来得及刷新.
W1nds 2011-11-26
  • 打赏
  • 举报
回复
有这种 情况?
学习了
tcige 2011-11-26
  • 打赏
  • 举报
回复
CloseHandle
PC_9527 2011-11-24
  • 打赏
  • 举报
回复
但是服务如果根本没有启动,是否情况也是一样?必须要 restarted?
Gloveing 2011-11-23
  • 打赏
  • 举报
回复
MSDN 上说的很清楚的:

The DeleteService function marks 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.

15,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 进程/线程/DLL
社区管理员
  • 进程/线程/DLL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧