开发者

Check to see if "Server" service is running - Multilingual C#.Net

I need to check and see if the "Server" service is running. Easy enough, using a method like this: How can I verify if a Windows Service is running

The problem comes in when the OS installation is not English. For example on a 开发者_StackOverflowWindows installation, the "Server" service is known as "Serveur". Obviously I don't want to hardcode separate languages into my app. Anyone have any good ideas for doing this cleanly?


Test out the following code and see what results you get, you may be surprised...

using System.ServiceProcess;

var controller = new ServiceController("LanmanServer");

Console.WriteLine(controller.ServiceName); // <- this is the unique name

Console.WriteLine(controller.DisplayName); // <- this is subject to change


Like the others, I suspect that the service name doesn't change across languages. It's usually the display name that changes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜