如何以编程方式发现正在运行的应用程序是否已安装? [英] How to programmatically discover whether the running application is installed?
本文介绍了如何以编程方式发现正在运行的应用程序是否已安装?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望程序检查它是否已安装在计算机上(使用Clickonce)还是正在运行(例如,通过Visual Studio)。
I want the program to check if it's installed on the computer (using Clickonce) or just being run (e.g. by Visual Studio).
编辑:不可重复>如何检测该C# Windows Forms代码是在Visual Studio中执行的?。 例如。表示例如。
Not a duplicate of How to detect that C# Windows Forms code is executed within Visual Studio? . "e.g." means for example.
推荐答案
您可以使用 ApplicationDeployment.IsNetworkDeployed 属性。请注意,这仅适用于ClickOnce安装。
You can use the ApplicationDeployment.IsNetworkDeployed property. Please note that this only works with ClickOnce installations.
private void CheckApplicationStatus() {
if (ApplicationDeployment.IsNetworkDeployed) {
// Do something that needs doing when the application is installed using ClickOnce.
} else {
// Do something that needs doing when the application is run from VS.
}
}
这篇关于如何以编程方式发现正在运行的应用程序是否已安装?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文