Wie kann ich zu listBox1 alle Prozessnamen und auch jedes Prozesssymbol daneben hinzufügen, wie im Task-Manager?C#

Ein Treffpunkt für C#-Programmierer
Anonymous
 Wie kann ich zu listBox1 alle Prozessnamen und auch jedes Prozesssymbol daneben hinzufügen, wie im Task-Manager?

Post by Anonymous »

Code: Select all

Process[] processlist = Process.GetProcesses();
foreach (Process theprocess in processlist)
{
listBox1.Items.Add(theprocess.ProcessName);
icons.Add(Icon.ExtractAssociatedIcon(theprocess.MainModule.FileName));
}
Auf diese Weise füge ich alle Prozesse zur listBox1 hinzu.

Aber mir wird der Ausnahmezugriff verweigert (ich habe Administratorrechte und habe das Visual Studio als Administrator ausgeführt) in der Zeile:

Code: Select all

icons.Add(Icon.ExtractAssociatedIcon(theprocess.MainModule.FileName));
Win32Exception: Zugriff verweigert

Code: Select all

System.ComponentModel.Win32Exception was unhandled
HResult=-2147467259
Message=Access is denied
Source=System
ErrorCode=-2147467259
NativeErrorCode=5
StackTrace:
at System.Diagnostics.ProcessManager.OpenProcess(Int32 processId, Int32 access, Boolean throwIfExited)
at System.Diagnostics.NtProcessManager.GetModuleInfos(Int32 processId, Boolean firstModuleOnly)
at System.Diagnostics.NtProcessManager.GetFirstModuleInfo(Int32 processId)
at System.Diagnostics.Process.get_MainModule()
at HardwareMonitoring.Form1..ctor() in d:\C-Sharp\HardwareMonitoring\HardwareMonitoring\Hardwaremonitoring\Form1.cs:line 124
at HardwareMonitoring.Program.Main() in d:\C-Sharp\HardwareMonitoring\HardwareMonitoring\Hardwaremonitoring\Program.cs:line 17
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
Was ich tun möchte, ist, in der listBox1 alle Prozesse aufzulisten und neben jedem Prozess auf der rechten Seite auch sein Logo anzuzeigen. Genau wie es im Windows Task-Manager angezeigt wird. Wie kann ich das machen?

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post