我机器上的进程...... [英] Processes on my machine...
本文介绍了我机器上的进程......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么这不起作用?
我还想知道如何要求微软提供一些特定的方法,例如在计算机上读取活动和非活动进程的数量? />
如何将其转换为Web方法?
如何控制从浏览器发布到应用程序的信息,反之亦然?
使用System;
使用System.Collections.Generic;
使用System.Linq;
使用System.Text;
使用System.Diagnostics;
命名空间TestOne
{
class program
{
static void Main(string [] args)
{
EnumMods( 0);
Console.ReadKey();
}
static void EnumMods(int PID)
{
处理theProc = null;
try
{
theProc = Process.GetProcessById(PID);
}
catch(ArgumentException ex){
Console.WriteLine(ex.Message);
返回;
}
Console.WriteLine(以下是加载的模块:{0},theProc.ProcessName);
ProcessModuleCollection theMods = theProc.Modules;
foreach(ProcessModule pm in theMods)
{
String info = string.Format( - > Mod Name:{0},pm.ModuleName);
Console.WriteLine(info);
}
}
}
}
例外是:
错误
以下是加载的模块:Idle
未处理的异常:System.ComponentModel.Win32Exception:无法枚举t
he流程模块。
在System.Diagnostics.NtProcessManager.GetModuleInfos(Int32 processId,Boolea
n firstModuleOnly)
at System.Diagnostics.ProcessManager.GetModuleInfos(Int32 processId)
at System.Diagnostics.Process。 get_Modules()
at TestOne.Program.EnumMods(Int32 PID)in c:\ usersrs \slyth_000 \documents\visual
studio 2010 \Projects\TestOne\TestOne \ Program .cs:第29行
在TestOne.Program.Main(String [] args)中c:\users \slyth_000 \documents\visual
studio 2010 \Projects\TestOne \ TestOne\Program.cs:第13行
按任意键继续。 。 。
解决方案
我不知道你打算在Windows中列出所有正在运行的进程是什么意思。
也许Web中的一些远程状态?
但无论如何。如果要列出所有正在运行的进程并列出进程的所有已加载模块,则需要提升权限。
普通用户无法列出Windows中所有正在运行的进程。
一个很好的灵感来看一下程序 Process Explorer [ ^ 来自微软。它可以帮助您验证您能够看到的内容。
对于Web方法,网站..您的计划是什么? REST API,SOAP,ASP.NET站点?
错误
以下是加载的模块:Idle
未处理的异常:System.ComponentModel.Win32Exception:无法枚举t
他处理模块。
在System.Diagnostics.NtProcessManager .GetModuleInfos(Int32 processId,Boolea
n firstModuleOnly)
在System.Diagnostics.ProcessManager.GetModuleInfos(Int32 processId)
在System.Diagnostics。 Process.get_Modules()
at TestOne.Program.EnumMods(Int32 PID)in c:\ usersrs \ _slyth_000 \ _documents \ visual
studio 2010 \ Projects\TestOne\TestOne\Program.cs:第29行
在TestOne.Program.Main(String [] args)中的c:\ usersrs \slyth_000 \documents \ visual
studio 2010 \Projects\TestOne\TestOne\Program.cs:第13行
按任意键继续。 。
Why doesn't this quite work?
I would also like to know how to ask Microsoft to include some specific methods such as reading the number of processes active and inactive on a computer?
How would I turn this to a web method?
How do I control the information that is posted across from the browser to the application and the other way round?
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Diagnostics; namespace TestOne { class Program { static void Main(string[] args) { EnumMods(0); Console.ReadKey(); } static void EnumMods(int PID) { Process theProc = null; try { theProc = Process.GetProcessById(PID); } catch (ArgumentException ex) { Console.WriteLine(ex.Message); return; } Console.WriteLine("Here are the loaded modules for: {0}", theProc.ProcessName); ProcessModuleCollection theMods = theProc.Modules; foreach (ProcessModule pm in theMods) { String info = string.Format("-> Mod Name: {0}", pm.ModuleName); Console.WriteLine(info); } } } }
The exception is:
Error Here are the loaded modules for: Idle Unhandled Exception: System.ComponentModel.Win32Exception: Unable to enumerate t he process modules. at System.Diagnostics.NtProcessManager.GetModuleInfos(Int32 processId, Boolea n firstModuleOnly) at System.Diagnostics.ProcessManager.GetModuleInfos(Int32 processId) at System.Diagnostics.Process.get_Modules() at TestOne.Program.EnumMods(Int32 PID) in c:\users\slyth_000\documents\visual studio 2010\Projects\TestOne\TestOne\Program.cs:line 29 at TestOne.Program.Main(String[] args) in c:\users\slyth_000\documents\visual studio 2010\Projects\TestOne\TestOne\Program.cs:line 13 Press any key to continue . . .
解决方案
I do not know what you intention is for listing all running process in Windows.
Perhaps some remote status in Web ?
But anyway. If you want to list all running process and list all the loaded modules for a process, you need elevated permission.
A normal user cannot list all running processes in Windows.
A good inspiration is to look at the program Process Explorer[^] from Microsoft. It can help you to verify what you are able to see.
And for a Web method, web sites.. What is your plan? REST API, SOAP, ASP.NET Site?
Error
Here are the loaded modules for: Idle
Unhandled Exception: System.ComponentModel.Win32Exception: Unable to enumerate t
he process modules.
at System.Diagnostics.NtProcessManager.GetModuleInfos(Int32 processId, Boolea
n firstModuleOnly)
at System.Diagnostics.ProcessManager.GetModuleInfos(Int32 processId)
at System.Diagnostics.Process.get_Modules()
at TestOne.Program.EnumMods(Int32 PID) in c:\users\slyth_000\documents\visual
studio 2010\Projects\TestOne\TestOne\Program.cs:line 29
at TestOne.Program.Main(String[] args) in c:\users\slyth_000\documents\visual
studio 2010\Projects\TestOne\TestOne\Program.cs:line 13
Press any key to continue . . .
这篇关于我机器上的进程......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文