Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Current process information

Current process information

Scheduled Pinned Locked Moved C#
help
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    a fatemeh
    wrote on last edited by
    #1

    here is the problem which I come across with: I want to get process name ,application name and it's window title name with the code below

    listView1.Columns.Add("CurrentProcess", 2000);
    listView1.Columns.Add("CurrentProcessPID", 500);
    listView1.Columns.Add("CurrentApplicationname", 2000);

    listView1.Items.Insert(1,Process.GetCurrentProcess().ToString());
    listView1.Items.Insert(2,Process.GetCurrentProcess().MainWindowTitle);
    listView1.Items.Insert(3,Process.GetCurrentProcess().Id.ToString());

    but when I run my code I get this result system.diagnostics.process(currentApplication on ByPId.vshost) form1 I enter this code to run in a timer tick so I use other application in the middle of this running code but I just get the result above. I would appreciate any commend

    L M 2 Replies Last reply
    0
    • A a fatemeh

      here is the problem which I come across with: I want to get process name ,application name and it's window title name with the code below

      listView1.Columns.Add("CurrentProcess", 2000);
      listView1.Columns.Add("CurrentProcessPID", 500);
      listView1.Columns.Add("CurrentApplicationname", 2000);

      listView1.Items.Insert(1,Process.GetCurrentProcess().ToString());
      listView1.Items.Insert(2,Process.GetCurrentProcess().MainWindowTitle);
      listView1.Items.Insert(3,Process.GetCurrentProcess().Id.ToString());

      but when I run my code I get this result system.diagnostics.process(currentApplication on ByPId.vshost) form1 I enter this code to run in a timer tick so I use other application in the middle of this running code but I just get the result above. I would appreciate any commend

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      whenever your app does something, it IS the current process. Therefore, GetCurrentProcess() isn't going to help you getting information about other processes. The Process class does hold what you need, however, be aware there are a number of system processes you are not allowed to get information about (You would get some kind of access violation when you try). An alternative route would be using WMI, probably with the exact same limitations. :)

      Luc Pattyn [My Articles] Nil Volentibus Arduum

      A 1 Reply Last reply
      0
      • L Luc Pattyn

        whenever your app does something, it IS the current process. Therefore, GetCurrentProcess() isn't going to help you getting information about other processes. The Process class does hold what you need, however, be aware there are a number of system processes you are not allowed to get information about (You would get some kind of access violation when you try). An alternative route would be using WMI, probably with the exact same limitations. :)

        Luc Pattyn [My Articles] Nil Volentibus Arduum

        A Offline
        A Offline
        a fatemeh
        wrote on last edited by
        #3

        thanks a lot; I would like to write an application to run at the back ground( I mean do such thing except for itself); do you recommend any thing?

        1 Reply Last reply
        0
        • A a fatemeh

          here is the problem which I come across with: I want to get process name ,application name and it's window title name with the code below

          listView1.Columns.Add("CurrentProcess", 2000);
          listView1.Columns.Add("CurrentProcessPID", 500);
          listView1.Columns.Add("CurrentApplicationname", 2000);

          listView1.Items.Insert(1,Process.GetCurrentProcess().ToString());
          listView1.Items.Insert(2,Process.GetCurrentProcess().MainWindowTitle);
          listView1.Items.Insert(3,Process.GetCurrentProcess().Id.ToString());

          but when I run my code I get this result system.diagnostics.process(currentApplication on ByPId.vshost) form1 I enter this code to run in a timer tick so I use other application in the middle of this running code but I just get the result above. I would appreciate any commend

          M Offline
          M Offline
          markovl
          wrote on last edited by
          #4

          I second what Luc said above. Just as a hint, if you need information for the processes currently running on the local system, you could use the Process.GetProcesses static method. But I have to ask... What's wrong with Windows Task Manager?

          2A

          A 1 Reply Last reply
          0
          • M markovl

            I second what Luc said above. Just as a hint, if you need information for the processes currently running on the local system, you could use the Process.GetProcesses static method. But I have to ask... What's wrong with Windows Task Manager?

            2A

            A Offline
            A Offline
            a fatemeh
            wrote on last edited by
            #5

            thanks for your comment; I need it through a program .. what I mean here is currently running application but not this application;

            M 1 Reply Last reply
            0
            • A a fatemeh

              thanks for your comment; I need it through a program .. what I mean here is currently running application but not this application;

              M Offline
              M Offline
              markovl
              wrote on last edited by
              #6

              Well, an application is just that - a process. If you mean you need the processes that Task Managers displays in the Applications tab - another hint - that's a process that has a window, and if it has a window it should have a window handle. Read about the Process class on MSDN, see what kind of properties and methods it has - the answer is all there (and here actually), so it's up to you to do the rest.

              2A

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups