如何在运行时找到作为Windows服务运行的exe的位置?

mrt*_*ndi 2 .net windows-services

如何在运行时找到作为Windows服务运行的exe的位置?

小智 10

使用注册表查找:

例如

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\' + ServiceDisplayName;
Run Code Online (Sandbox Code Playgroud)

然后读取ImagePath价值.