Unexplained Win32_Process (WinForms)



  • There's a process-to-set code:

    var process = new StringBuilder(); 
    ManagementObjectSearcher searcherProc = new ManagementObjectSearcher("root\\CIMV2", "Select Name, CommandLine From Win32_Process"); 
    foreach (ManagementObject instance in searcherProc.Get()) 
    { 
    process.AppendLine(string.Format("Процесс: {0}", instance["Name"])); 
    } 
    /*foreach (System.Diagnostics.Process winProc in System.Diagnostics.Process.GetProcesses()) 
    { 
    processi.AppendLine(string.Format("Процесс: {0}, Имя: {1}.exe", winProc.Id, winProc.ProcessName, )); 
    }*/ 
    show_information(process.ToString());
    

    The methods work only Name♪ Use Caption or OSName The compiler makes a mistake: введите сюда описание изображения

    How to correct the error or other means of the language to release information on the processes (all initiated): Name, ID, Way, Memory?



  • In your request:

    Select Name, CommandLine From Win32_Process
    

    You only choose fields. Name and CommandLine♪ To obtain the field values Caption and OSName You can't, you just didn't pick them.

    That's what it says, but you probably didn't look at it.

    Just add the necessary fields to the request.


    Without WMI, the information you gave could be obtained, for example, by moving Process.GetProcesses():

    var info = from process in Process.GetProcesses()
               select new { process.ProcessName, process.Id, process.WorkingSet64};
    

    But unfortunately, you don't get the information on the command line - if you need it, you'll still have to use WMI.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2