如何使用C#知道正在运行的进程是桌面应用程序还是商店应用程序或Web应用程序 [英] How to know whether running process is of Desktop app or store app or web application using C#

查看:95
本文介绍了如何使用C#知道正在运行的进程是桌面应用程序还是商店应用程序或Web应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过Getprocess() 

I was trying to know whether running app is web(like ie and chrome)/store or desktop using the process by Getprocess()  

但是我找不到任何可能告诉应用类别的相关属性.

but i am unable to find any relevant property that may actually tell app category.

Process []进程= Process.GetProcesses();

            foreach(正在处理的过程prs)
            {
                var a = prs.GetType();
            }

Process[] process = Process.GetProcesses();

            foreach (Process prs in process)
            {
                var a = prs.GetType();
            }

有没有办法获取此类信息?

is there any way to get such info?

推荐答案

实际上没有任何方法可以可靠地知道这一点. Web应用程序只是网页的宿主.每个Web应用程序的工作方式都不相同,一个应用程序可以托管任意数量的网页,也可以为每个应用程序创建一个单独的应用程序.建立这种类型的唯一方法 应用程序将查看您关心的每个浏览器并根据其行为构建逻辑.但是,这不会捕获您不支持的浏览器,也不一定能与该浏览器的较新版本一起使用.

There really isn't any way to know this reliably. A web app is simply a host for web pages. Each web app works differently and a single app may be hosting any # of web pages, or it may create a separate app for each one. The only way to build this type of app is to look at each of the browsers you care about and build logic based upon their behavior. However this won't catch browsers you don't support nor will it necessarily work with newer versions of the same browser.

您最好的选择是寻找您关心的主要浏览器(IE,Chrome等).如果看到这些进程名称,则说明浏览器正在运行.但是在浏览器中打开标签页需要特定于浏览器的逻辑).这个特殊的问题有 在这些论坛上被问了很多遍,不再重复.您可以通过Google搜索该问题的许多可能解决方案.

Your best bet is to look for the main browsers you care about (IE, chrome, etc). If you see those process names then you know the browser is running. But getting the tabs open in the browser requires browser-specific logic). This particular question has been asked so many times on these forums that it doesn't bear repeating. You can google for the many possible solutions to that problem.

迈克尔·泰勒
http://www.michaeltaylorp3.net

Michael Taylor
http://www.michaeltaylorp3.net


这篇关于如何使用C#知道正在运行的进程是桌面应用程序还是商店应用程序或Web应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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