public static string GetWindowsServiceInstallPath(string ServiceName)
{
string key = @"SYSTEM\CurrentControlSet\Services\" + ServiceName;
string path = Registry.LocalMachine.OpenSubKey(key).GetValue("ImagePath").ToString();
//替換掉雙引號
path = path.Replace("\"", string.Empty);
FileInfo fi = new FileInfo(path);
return fi.Directory.ToString();
} string