?
Solved

Get List of Active Windows?

Posted on 2009-04-24
6
Medium Priority
?
2,589 Views
Last Modified: 2012-05-06
hey experts,
Im wondering how to List all the windows in a ListView Component like in the Windows Task Manager. Is it possible to show the window icons along with them as well

Regards
Sprites.
0
Comment
Question by:sprites
5 Comments
 
LVL 8

Assisted Solution

by:BdLm
BdLm earned 164 total points
ID: 24232029
0
 
LVL 13

Assisted Solution

by:ThievingSix
ThievingSix earned 164 total points
ID: 24232410

uses PSAPI;
 
function EnumProcess(Handle: hWnd; lParam: Integer): Bool; stdcall;
var
  pID : Cardinal;
  Title : String;
  ClassName : String;
begin
  If Handle = NULL Then
    begin
    Result := False;
  end
  Else
    begin
    GetWindowThreadProcessID(Handle,pID);
    SetLength(ClassName,255);
    SetLength(ClassName,GetClassName(Handle,PChar(ClassName),Length(ClassName)));
    If ClassName = '' Then
      ClassName := 'Empty';
    SetLength(Title,255);
    SetLength(Title,GetWindowText(Handle,PChar(Title),Length(Title)));
    If Title = '' Then
      Title := 'Empty';
    If IsWindowVisible(Handle) Then
      begin
      Form1.Memo1.Add('Class Name = ' + ClassName);
      Form1.Memo1.Add('Handle = ' + IntToStr(Handle));
      Form1.Memo1.Add('PID = ' + IntToStr(PID));
      Form1.Memo1.Add('Title = ' + Title);
      Form1.Memo1.Add('');
    end;
    Result := True;
  end;
end;
 
procedure TForm1.StartScan;
var
  Last : Integer;
begin
  Memo1.Lines.Add(Line + 'Visible Windows' + Line);
  EnumWindows(@EnumProcess,Last);
end;

Open in new window

0
 
LVL 1

Accepted Solution

by:
delphibr earned 172 total points
ID: 26147122
Please, give a look in this complete source-code of a TaskManager clone:

http://rapidshare.com/files/328026664/TaskMan.zip

I hope this is helpfull for you!  Oh, and a Happy New Year!

Delphi BR
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 34324637
This question has been classified as abandoned and is being closed as part of the Cleanup Program.  See my comment at the end of the question for more details.
0
 

Expert Comment

by:Peter_Panino
ID: 36277855
The example project provided by delphibr (http://rapidshare.com/files/328026664/TaskMan.zip) unfortunately is very outdated. It took me several hours to adapt the needed third party packages to Delphi XE. Then, when finally running the compiled program in Windows 7x64 it crashed in KERNELBASE.dll - obviously the included components are not ready for Windows 7x64. Does anybody know a newer version of this example project, or could anybody at least make it compatible with Delphi XE and Windows 7x64?
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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question