You are currently viewing How to Get a List of Running Applications in Windows Using C# and Java

Monitoring running applications is a common task in desktop utilities, monitoring tools, or system dashboards. In this tutorial, we’ll walk through how to:

  • Get a list of running applications (visible windows only)
  • Use C# with Windows Forms and Java with Swing
  • Display the app list in a ListView (or similar UI control)

Prerequisites

  • Basic understanding of either C# (.NET) or Java (Swing/AWT)
  • Windows OS (this guide uses Windows API features)

Part 1: C# – Using System.Diagnostics and Win32 API

Create a WinForms App

Open Visual Studio → Create new Windows Forms App (.NET)

Add a ListView to your Form

In Form1.cs:

C#
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
        GetRunningApps();
    }

    private void GetRunningApps()
    {
        listView1.View = View.Details;
        listView1.Columns.Add("App Name", 300);

        foreach (Process p in Process.GetProcesses())
        {
            if (!string.IsNullOrEmpty(p.MainWindowTitle))
            {
                listView1.Items.Add(new ListViewItem(p.MainWindowTitle));
            }
        }
    }
}

Notes:

  • Process.GetProcesses() gets all system processes.
  • MainWindowTitle filters only apps with UI (not background processes).
  • You can also display p.ProcessName for technical names.

Part 2: Java – Using com.sun.jna to Access Win32 API

Java by default does not access Windows processes easily, but with JNA (Java Native Access), you can call native APIs.

Add JNA to your project (Maven example)

XML
<dependency>
  <groupId>net.java.dev.jna</groupId>
  <artifactId>jna</artifactId>
  <version>5.13.0</version>
</dependency>
<dependency>
    <groupId>net.java.dev.jna</groupId>
    <artifactId>jna-platform</artifactId>
    <version>5.13.0</version>
</dependency>

Create the Java UI (Swing List)

Java
import com.sun.jna.*;
import com.sun.jna.platform.win32.*;
import com.sun.jna.win32.*;
import javax.swing.*;
import java.awt.*;

public class RunningApps {

    public static void main(String[] args) {
        JFrame frame = new JFrame("Running Apps");
        DefaultListModel<String> listModel = new DefaultListModel<>();
        JList<String> appList = new JList<>(listModel);
        JScrollPane scrollPane = new JScrollPane(appList);

        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(400, 300);
        frame.add(scrollPane, BorderLayout.CENTER);

        // Get window titles using EnumWindows
        User32.INSTANCE.EnumWindows((hWnd, data) -> {
            char[] buffer = new char[512];
            User32.INSTANCE.GetWindowText(hWnd, buffer, 512);
            String windowTitle = Native.toString(buffer);
            if (!windowTitle.isBlank()) {
                listModel.addElement(windowTitle);
            }
            return true;
        }, null);

        frame.setVisible(true);
    }

    public interface User32 extends StdCallLibrary {
        User32 INSTANCE = Native.load("user32", User32.class);

        boolean EnumWindows(WNDENUMPROC lpEnumFunc, Pointer arg);
        int GetWindowText(WinDef.HWND hWnd, char[] lpString, int nMaxCount);

        interface WNDENUMPROC extends Callback {
            boolean callback(WinDef.HWND hWnd, Pointer arg);
        }
    }
}

Notes:

  • This uses EnumWindows to loop through top-level windows.
  • GetWindowText fetches window titles.
  • You can filter with IsWindowVisible if needed.

Output: What You’ll See

Both implementations give you a scrollable list view showing:

  • Active window titles (e.g., “Visual Studio Code”“Google Chrome”, etc.)
  • Only visible applications, not background processes

Security Note

  • For full access to all processes (in C#), run as admin.
  • In Java, JNA is powerful but requires trust; avoid using native access for untrusted operations.
Please follow and like us:

Leave a Reply