如何检查是否一个程序正在使用.NET? [英] How to check if a program is using .NET?
本文介绍了如何检查是否一个程序正在使用.NET?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们能检查正在运行的应用程序或程序使用的.Net框架来执行自己?
Can we check if a running application or a program uses .Net framework to execute itself?
推荐答案
有一个诀窍我曾经从斯科特Hanselman的<一个教训href="http://www.hanselman.com/blog/WhatGreatNETDevelopersOughtToKnowMoreNETInterviewQuestions.aspx">list面试的问题。您可以通过使用容易列出运行.NET在命令提示符下的所有程序:
There's a trick I once learned from Scott Hanselman's list of interview questions. You can easily list all programs running .NET in command prompt by using:
任务列表/ Mmscor *
它会列出具有所有进程 mscor *
之间的加载模块。
It will list all processes that have mscor*
amongst their loaded modules.
我们可以在code采用同样的方法:
We can apply the same method in code:
public static bool IsDotNetProcess(this Process process)
{
var modules = process.Modules.Cast<ProcessModule>().Where(
m => m.ModuleName.StartsWith("mscor", StringComparison.InvariantCultureIgnoreCase));
return modules.Any();
}
这篇关于如何检查是否一个程序正在使用.NET?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文