How to programmatically discover whether the running application is installed? [closed]

此生再无相见时 提交于 2020-01-07 08:09:21

问题


I want the program to check if it's installed on the computer (using Clickonce) or just being run (e.g. by Visual Studio).

EDIT: Not a duplicate of How to detect that C# Windows Forms code is executed within Visual Studio? . "e.g." means for example.


回答1:


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.
    }
}


来源:https://stackoverflow.com/questions/12919784/how-to-programmatically-discover-whether-the-running-application-is-installed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!