如何更改在.NET中的Windows服务的启动类型(安装后)? [英] How do I change a Windows Service's startup type in .NET (post-install)?
问题描述
我有一个程序,安装服务,而我希望能够给用户选择稍后更改启动类型设置为自动。
I have a program that installs a service, and I'd like to be able to give the user the option later on to change the startup type to "Automatic".
该操作系统是XP - (的Windows API)。如果它使任何区别
The OS is XP - if it makes any difference (Windows APIs?).
我怎样才能做到这一点。NET中? C#如果可能的话! :)
How can I do this in .NET? C# if possible! :)
推荐答案
您可以使用OpenService()和ChangeServiceConfig()原生的Win32 API用于这一目的。我相信,有在课程上的 pinvoke.net 以及一些信息:// MSDN。 microsoft.com/en-us/library/ms681987%28VS.85%29.aspx相对=nofollow> MSDN 。您可能要检查出<一href="http://blogs.msdn.com/bclteam/archive/2008/06/23/p-invoke-interop-assistant-justin-van-patten.aspx"相对=nofollow> P /调用Interopt助理。
You can use the OpenService() and ChangeServiceConfig() native Win32 APIs for that purpose. I believe that there is some information on pinvoke.net and of course on MSDN. You might want to check out the P/Invoke Interopt Assistant.
这篇关于如何更改在.NET中的Windows服务的启动类型(安装后)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!