Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 257981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:08:33+00:00 2026-05-11T22:08:33+00:00

I would like to develop an application (that runs at all times in the

  • 0

I would like to develop an application (that runs at all times in the background I guess) to track the usage of applications (msword, excel, powerpoint, *.exe, etc.).

I can handle posting the data to a database but don’t exactly know where to start with monitoring running applications (when they start, when they stop). Anyone have any clues?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T22:08:33+00:00Added an answer on May 11, 2026 at 10:08 pm

    You can periodically poll a list of the running processes using System.Diagnostics.Process.GetProcesses().

    This following code outputs information about starting and exiting processes. Exiting system processes won’t be recognized.

    class Program
    {
        struct ProcessStartTimePair
        {
            public Process Process { get; set; }
            public DateTime StartTime { get; set; }
            public DateTime ExitTime
            {
                get
                {
                    return DateTime.Now; // approximate value
                }
            }
    
            public ProcessStartTimePair(Process p) : this()
            {
                Process = p;
                try
                {
                    StartTime = p.StartTime;
                }
                catch (System.ComponentModel.Win32Exception)
                {
                    StartTime = DateTime.Now; // approximate value
                }
            }
        }
    
        static void Main(string[] args)
        {
            List<ProcessStartTimePair> knownProcesses = new List<ProcessStartTimePair>();
            while (true)
            {
                foreach (Process p in Process.GetProcesses())
                {
                    if (!knownProcesses.Select(x => x.Process.Id).Contains(p.Id))
                    {
                        knownProcesses.Add(new ProcessStartTimePair(p));
                        Console.WriteLine("Detected new process: " + p.ProcessName);
                    }
                }
    
                for (int i = 0; i < knownProcesses.Count; i++) 
                {
                    ProcessStartTimePair pair = knownProcesses[i];
                    try
                    {
                        if (pair.Process.HasExited)
                        {
                            Console.WriteLine(pair.Process.ProcessName + " has exited (alive from {0} to {1}).", pair.StartTime.ToString(), pair.ExitTime.ToString());
                            knownProcesses.Remove(pair);
                            i--; // List was modified, 1 item less
                            // TODO: Store in the info in the database
                        }
                    }
                    catch (System.ComponentModel.Win32Exception)
                    {
                        // Would have to check whether the process still exists in Process.GetProcesses().
                        // The process probably is a system process.
                    }
                }
                Console.WriteLine();
                System.Threading.Thread.Sleep(1000);
            }
        }
    }
    

    You probably can simply ignore system processes that don’t let you read the HasExited property.

    Edit

    Here’s a .net 2.0 version:

        static void Main(string[] args)
        {
            List<ProcessStartTimePair> knownProcesses = new List<ProcessStartTimePair>();
            while (true)
            {
                foreach (Process p in Process.GetProcesses())
                {
                    if (!ProcessIsKnown(knownProcesses, p.Id))
                    {
                        knownProcesses.Add(new ProcessStartTimePair(p));
                        Console.WriteLine("Detected new process: " + p.ProcessName);
                    }
                }
    
                for (int i = 0; i < knownProcesses.Count; i++) 
                [...]
            }
        }
    
        static bool ProcessIsKnown(List<ProcessStartTimePair> knownProcesses, int ID)
        {
            foreach (ProcessStartTimePair pstp in knownProcesses)
            {
                if (pstp.Process.Id == ID)
                {
                    return true;
                }
            }
            return false;
        }
    

    Note that the code could be improved and only shows the concept.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to develop a mobile application that is able to access all
I'd like to develop a PHP application that users would download and then could
I would like to develop an application that will receive pictures from a camera
I would like to develop Adobe Flex applications using Linux and a free environment.
I would like to use Apple's Xcode IDE to develop applications on the OS
I would like to use javascript to develop general-purpose GUI applications. Initially these are
I'm a C# developer. I develop both Windows & Web Applications. I would like
I'd like to develop an application that can listen for unencrypted sensitive information (info
I would like to develop an application similar to Thinix touch What tools would
I would like to develop an iPhone application, but I do not have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.