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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. How to count the running applications?

How to count the running applications?

Scheduled Pinned Locked Moved C#
questioncsharptutorial
7 Posts 4 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.
  • Y Offline
    Y Offline
    yyf
    wrote on last edited by
    #1

    Hi, How can I count the total number of WinWord that is running in my C# application? Thanks in advance.

    S N T 3 Replies Last reply
    0
    • Y yyf

      Hi, How can I count the total number of WinWord that is running in my C# application? Thanks in advance.

      S Offline
      S Offline
      SherKar
      wrote on last edited by
      #2

      hi see the article of windowhiding this will get u all open windows then search for (winword) in the windows.Title u will have the count

      1 Reply Last reply
      0
      • Y yyf

        Hi, How can I count the total number of WinWord that is running in my C# application? Thanks in advance.

        N Offline
        N Offline
        Nick Parker
        wrote on last edited by
        #3

        yyf wrote: How can I count the total number of WinWord that is running in my C# application? The follow will work:

        using System.Diagnostics;
        Process[] pa = Process.GetProcessesByName("WINWORD");
        if(pa != null)
        {
        int count = pa.Length;
        }

        - Nick Parker
          My Blog

        1 Reply Last reply
        0
        • Y yyf

          Hi, How can I count the total number of WinWord that is running in my C# application? Thanks in advance.

          T Offline
          T Offline
          turbochimp
          wrote on last edited by
          #4

          I would just use the tools available in System.Diagnostics. Example: System.Diagnostics.Process[] runningProcess = System.Diagnostics.Process.GetProcessesByName("WinWord"); foreach(System.Diagnostics.Process proc in runningProcess) Console.WriteLine(proc.Id);

          The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’

          Y 1 Reply Last reply
          0
          • T turbochimp

            I would just use the tools available in System.Diagnostics. Example: System.Diagnostics.Process[] runningProcess = System.Diagnostics.Process.GetProcessesByName("WinWord"); foreach(System.Diagnostics.Process proc in runningProcess) Console.WriteLine(proc.Id);

            The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’

            Y Offline
            Y Offline
            yyf
            wrote on last edited by
            #5

            Thank all of you. This is very helpful! Here is what I did using Win32API(I import the user32.dll and put it into my Win32API class), but it doesn't work as I except. public int CheckWord { int num; string lpText = new string((char) 0, 100); IntPtr hWnd = Win32API.GetWindow(Win32API.GetDesktopWindow(), Win32API.GW_CHILD); int UStnNumber = 0; while ( !hWnd.Equals(IntPtr.Zero) ) { num = Win32API.RealGetWindowClass(hWnd, lpText, lpText.Length); if ( num > 0 ) { if ( lpText.Equals("OpusApp") ) { UStnNumber ++; } } hWnd = Win32API.GetWindow( hWnd, Win32API.GW_HWNDNEXT ); } return UStnNumber; } Do you know why?

            N 1 Reply Last reply
            0
            • Y yyf

              Thank all of you. This is very helpful! Here is what I did using Win32API(I import the user32.dll and put it into my Win32API class), but it doesn't work as I except. public int CheckWord { int num; string lpText = new string((char) 0, 100); IntPtr hWnd = Win32API.GetWindow(Win32API.GetDesktopWindow(), Win32API.GW_CHILD); int UStnNumber = 0; while ( !hWnd.Equals(IntPtr.Zero) ) { num = Win32API.RealGetWindowClass(hWnd, lpText, lpText.Length); if ( num > 0 ) { if ( lpText.Equals("OpusApp") ) { UStnNumber ++; } } hWnd = Win32API.GetWindow( hWnd, Win32API.GW_HWNDNEXT ); } return UStnNumber; } Do you know why?

              N Offline
              N Offline
              Nick Parker
              wrote on last edited by
              #6

              yyf wrote: but it doesn't work as I except. Do you know why? Did you try the code I showed as an example? - Nick Parker
                My Blog

              Y 1 Reply Last reply
              0
              • N Nick Parker

                yyf wrote: but it doesn't work as I except. Do you know why? Did you try the code I showed as an example? - Nick Parker
                  My Blog

                Y Offline
                Y Offline
                yyf
                wrote on last edited by
                #7

                Yes, I did. It works very well. But I just wonder why my way doesn't work.

                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