Changing the service's startup-type (Windows)

余生颓废 提交于 2019-12-05 15:35:42

You can also use the win32 API directly. I'd definitely recommend the WMI class; it makes it most likely that if there are changes in future versions of windows that your code still works.

I you want to be safe for future versions of Windows, better use WMI.

If you are not thinking beyond Windows 7, I recommend the WinAPI functions (OpenSCManager and ChangeServiceConfig come to mind). I find them easier to understand, and there are tons of code examples on how to use them. WMI on the other hand is still new, and not as well documented.

Just never, ever, edit the registry directly. The WinAPI or WMI interfaces exist to abstract the task from the way Windows handles the data internally. Bypassing them brings the biggest risk of breaking in the future.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!