Suraj Bhawal
Suraj Bhawal

Reputation: 413

getting all instances of explorer.exe processes?

i want to list all running processes into a self make taskbar control..

while i can get all processes just fine but serveral instances of explorer.exe won't list.(ive opened several folders it should list all but it only shows one.

following is the code i'm using to get all running processes

private void LoadApps()
{

    Process[] process = Process.GetProcesses();
    IntPtr child = IntPtr.Zero;
    panel.Children.Clear();

    foreach (Process p in process)
    {
        if(p.MainWindowHandle != IntPtr.Zero && p.MainWindowTitle.Length > 0)
        {
            System.Drawing.Icon ico = System.Drawing.Icon.ExtractAssociatedIcon(module.GetExecutablePath(p));
            Image btn = new Image();
            btn.Source = ico.ToImageSource();
            btn.Margin = new Thickness(4, 4, 4, 4);
            btn.Height = panel.Height;
            btn.Width = 32;
            btn.Tag = p.MainWindowHandle;
            panel.Children.Add(btn);
        }
    }
}

is there any other method where i can list running processes?

or is there a workaround with the used method..

Upvotes: 0

Views: 1381

Answers (1)

BendEg
BendEg

Reputation: 21088

The explorer.exe always just runs one time. If you want to get all opened explorer windows, than you have to use the WinAPI. This thread should help you: How find all windows?

Upvotes: 1

Related Questions