相关疑难解决方法(0)

查询是否禁用了Windows服务(不使用注册表)?

是否有.NET(C#)方法或API调用,我可以用来查询Windows服务是否被禁用?相关的MSDN文章就在这里.

我想避免直接查询注册表.下面是我现在正在使用的一些代码(并且它可以工作).然而,我正在寻找更优雅,更少侵入性的东西.

const String basepathStr = @"System\CurrentControlSet\services\";
String subKeyStr = basepathStr + servicenameStr;

using (RegistryKey key = Registry.LocalMachine.OpenSubKey(subKeyStr))
{
    return (int) key.GetValue("Start");
}
Run Code Online (Sandbox Code Playgroud)

我确实找到了一个简短的问题,但我希望得到一个更好的答案,因为答案可能已经过时(3年过去了).

c# registry service

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

c# ×1

registry ×1

service ×1