本人试了两种方法,效果都不理想。
方法一:无法获得文件夹
Process[] ps = Process.GetProcesses();
            foreach (Process p in ps)
            {
                
                if (p.MainWindowHandle != null)
                {
                    if (p.MainWindowTitle!="")
                    this.listBox1.Items.Add(p.MainWindowTitle);
                }
            }
方法二:获取了文件夹,但是无法获取无边框的窗口程序,比如金山WPS2012
    [DllImport("User32")] 
private extern static int GetWindow(int hWnd, int wCmd); [DllImport("User32")] 
private extern static int GetWindowLongA(int hWnd, int wIndx); [DllImport("user32", CharSet = CharSet.Auto)] 
private extern static int GetWindowTextLength(IntPtr hWnd); [DllImport("user32.dll")] 
private static extern bool GetWindowText(int hWnd, StringBuilder title, int maxBufSize); private const int GW_HWNDFIRST = 0; 
private const int GW_HWNDNEXT = 2; 
private const int GWL_STYLE = (-16); 
private const int WS_VISIBLE = 268435456; 
private const int WS_BORDER = 8388608; public List <string> GetRunApplicationList(Form appForm) 

    try 
    { 
        List <string> appString = new List <string>(); 
        int handle = (int)appForm.Handle; 
        int hwCurr; 
        hwCurr = GetWindow(handle, GW_HWNDFIRST); 
        while (hwCurr > 0) 
        {
            int isTask = (WS_VISIBLE | WS_BORDER); 
            int lngStyle = GetWindowLongA(hwCurr, GWL_STYLE); 
            bool taskWindow = ((lngStyle & isTask) == isTask); 
            if (taskWindow) 
            { 
                int length = GetWindowTextLength(new IntPtr(hwCurr)); 
                StringBuilder sb = new StringBuilder(2 * length + 1); 
                GetWindowText(hwCurr, sb, sb.Capacity); 
                string strTitle = sb.ToString(); 
                if (!string.IsNullOrEmpty(strTitle)) 
                { 
                    appString.Add(strTitle); 
                } 
            } 
            hwCurr = GetWindow(hwCurr, GW_HWNDNEXT); 
        } 
        return appString; 
    } 
    catch (Exception ex) 
    {
        throw new ApplicationException("读取应用程序信息时出错:" + ex.Message); 
        
    } 

private void button1_Click(object sender, EventArgs e)
        {
           List<string> list=new List<string>();
            list=GetRunApplicationList(this);
            foreach (var l in list)
            {
                textBox1.Text +=l+ "\r\n";
            }
        }求大神,如何获取任务栏上全部的应用程序???