Changing the service's startup-type (Windows)

天涯浪子 提交于 2019-12-07 11:14:12

问题


I was searching for ways to change the start-up type of a Windows service and I found 2 ways to do this...

By editing the Registry Or By using the WMI classes

I want to know which one is the best... I want my application to run properly on both Windows and Vista.


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/520517/changing-the-services-startup-type-windows

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