如何找到在运行时作为 Windows 服务运行的 exe 的位置? [英] How can I find the location of exe that runs as a windows service in run-time?

查看:36
本文介绍了如何找到在运行时作为 Windows 服务运行的 exe 的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

How can I find the location of exe that runs as a windows service in run-time?

推荐答案

.NET - Assembly.GetExecutingAssembly().Location(其他人已经建议了 Application.ExecutablePath,但是这需要对 System.Windows.Forms 的引用,而服务通常不需要)

.NET - Assembly.GetExecutingAssembly().Location (others have suggested Application.ExecutablePath, but this requires a reference to System.Windows.Forms, which a service normally doesn't need)

原生 - GetModuleFileName(NULL, ...)

这篇关于如何找到在运行时作为 Windows 服务运行的 exe 的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆