windows process count

Posted jizhiqiliao

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了windows process count相关的知识,希望对你有一定的参考价值。

In order to get the count of "Word" process, you can refer to the steps as follow.

First, you need to use "System.Runtime.InteropServices", then add .dll "Microsoft.Office.Interop.Word" from "NuGet". The specific operation is as follows:

Click "Manage NuGet Packages..." and type "Microsoft.Office.Interop.Word" in the search bar and download it.

 技术分享图片

技术分享图片

Then, You can use the following code to implement it.

int count = 0;
try
{
    Microsoft.Office.Interop.Word.Application winObj = (Microsoft.Office.Interop.Word.Application)Marshal.GetActiveObject("Word.Application");
    foreach (var item in winObj.Documents) // or winObj.Documents.Count
    {
        count++;
    }
}
catch (System.Runtime.InteropServices.COMException)
{
    count = 0;
}
textBox1.Text = count.ToString();

You can implement how to get count of all processes by using the following code.

Process[] pros = Process.GetProcesses();
int count = 0;
foreach (Process pro in pros)
{
    count++;
}
textBox1.Text = count.ToString();

以上是关于windows process count的主要内容,如果未能解决你的问题,请参考以下文章

sql [SQL查询片段]用于在命令行或通过R和其他工具使用SQL的快速代码段#tags:sql,R,text processing,命令li

Nginx——Nginx启动报错Job for nginx.service failed because the control process exited with error code(代码片段

很实用的JQuery代码片段(转)

20160226.CCPP体系详解(0036天)

asp.net页面实用代码片段

add application window with unknown token XXX Unable to add window;is your activity is running?(代码片段