string key = @"SYSTEM\CurrentControlSet\Services\";
var services = Registry.LocalMachine.OpenSubKey(key);
if (services == null)
{
return;
}
var serviceNameList = services.GetSubKeyNames().ToList();
if (serviceNameList != null && serviceNameList.Count > 0)
{
//serviceNameList= serviceNameList.Where(f=>f.Contains("K3CloudClienter")).ToList();
foreach (var serviceName in serviceNameList)
{
var serviceKey = Registry.LocalMachine.OpenSubKey($"{key}\\{serviceName}");
if (serviceKey != null)
{
var configValue = serviceKey.GetValue("ImagePath");
if (configValue == null)
{
continue;
}
System.Console.WriteLine(configValue.ToString());
}
}
}
标签:serviceKey,c#,路径,serviceNameList,services,key,注册表,var,null
From: https://www.cnblogs.com/ives/p/17481020.html