Example #1
0
 static void TestGetProcessIds()
 {
     MessageBox.Show(CurrentProcess.CommandLine);
     uint[] IDs = NativeProcess.GetProcessIds();
     if (null != IDs && IDs.Length > 0)
     {
         StringBuilder msg = new StringBuilder("{");
         msg.Append(IDs[0]);
         for (int i = 1; i < IDs.Length; i++)
         {
             msg.Append(", ").Append(IDs[i]);
         }
         msg.Append("}");
         MessageBox.Show(msg.ToString());
     }
     else
     {
         MessageBox.Show("Process IDs array was null or empty! Error code: " + NativeProcess.GetError());
     }
     ProcessInfo[] infos = NativeProcess.GetProcesses();
     if (null != infos && infos.Length > 0)
     {
         StringBuilder msg = new StringBuilder();
         for (int i = 0; i < infos.Length; i++)
         {
             msg.Append(infos[i].ProcessID).Append('\t').AppendLine(infos[i].ImageName);
         }
         MessageBox.Show(msg.ToString());
     }
     else
     {
         MessageBox.Show("ProcessInfos array was null or empty! Error code: " + NativeProcess.GetError());
     }
 }