Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3236
  • Last Modified:

Delphi XE2 win32 - List running application like task manager in Windows

Hello,

i'm searching a way to get a list of running application in Delphi XE2 win32
I have found a lot of code on the web but all of them are showing how to list "process"

I really need to get the list of running application like the Windows 7 Task manager do on the first Window

Does anyone know how to do?

Thanks for help
0
sibliege
Asked:
sibliege
1 Solution
 
mlmccCommented:
What are you trying to do with this tool?

mlmcc
0
 
Ferruccio AccalaiSenior developer, analyst and customer assistance Commented:
Windows function EnumWindows is available for this. You have just to use the right parameter to get just the value you need.
Try this code
function EnumWindowsProc(HWND: HWND; List: TStringList): BOOL; stdcall;
var
  s: string;
  IsVisible, IsOwned, IsAppWindow: Boolean;
begin
  Result := True; // carry on enumerating
  IsVisible := IsWindowVisible(HWND);
  if not IsVisible then
    exit;
  IsOwned := GetWindow(HWND, GW_OWNER)<>0;
  if IsOwned then
    exit;
  IsAppWindow := GetWindowLongPtr(HWND, GWL_STYLE) and WS_EX_APPWINDOW<>0;
  if not IsAppWindow then
    exit;
  SetLength(s, GetWindowTextLength(HWND));
  GetWindowText(HWND, PChar(s), Length(s)+1);
  List.Add(s);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  ListBox1.Clear;
  EnumWindows(@EnumWindowsProc, lparam(ListBox1.items));
end;

Open in new window

0
 
ThommyCommented:
0
 
sibliegeAuthor Commented:
perfectly what is was searching!
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now