seb24
asked on
List of taskbar 's runnig process?
I want to know how to get only the taskbar 's process ?
I know that the windows folders have "CabinetWClass" classname (and delphi application are "Tapplication"),but the
applications seem not to have rules.
I know that the windows folders have "CabinetWClass" classname (and delphi application are "Tapplication"),but the
applications seem not to have rules.
You could use EnumWindows to enumerate all top level windows. Then you have to check each window. Only windows with owner=0 and parent=0 are shown as buttons in the taskbar.
Is that what you want?
Regards, Madshi.
Is that what you want?
Regards, Madshi.
seb24
if yau are looking to get the taskbar use
var
hw: HWND;
begin
hw:= FindWindow('Shell_Traywnd' , nil);
here is an example of getting the taskbar then show it or hide it...
procedure TForm1.Button1Click(Sender : TObject);
var
hw: HWND;
begin
hw:= FindWindow('Shell_Traywnd' , nil);
if hw <> 0 then
if IsWindowVisible(hw) then
ShowWindow(hw, SW_HIDE)
else
ShowWindow(hw, SW_SHOW);
end;
Later
BoRiS
if yau are looking to get the taskbar use
var
hw: HWND;
begin
hw:= FindWindow('Shell_Traywnd'
here is an example of getting the taskbar then show it or hide it...
procedure TForm1.Button1Click(Sender
var
hw: HWND;
begin
hw:= FindWindow('Shell_Traywnd'
if hw <> 0 then
if IsWindowVisible(hw) then
ShowWindow(hw, SW_HIDE)
else
ShowWindow(hw, SW_SHOW);
end;
Later
BoRiS
seb24,
tell us a little bit more about what you want to do. Why did you reject Boris' answer? You should always write a comment when rejecting an answer, so we all know what didn't work or what it was that you didn't like.
Regards, Madshi.
tell us a little bit more about what you want to do. Why did you reject Boris' answer? You should always write a comment when rejecting an answer, so we all know what didn't work or what it was that you didn't like.
Regards, Madshi.
ASKER
I would known the processes who appear in the eplorer 's taskbar ,on the right of the "Start" button.
I tried the Madshi 's answer but I found again too much process.
ps:I'm on NT4 sp3.
////////////////////////// ////////// ////////// ////////// ////////
Unit seb;
Interface
Uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComCtrls;
Type
TForm1 = Class(TForm)
ListBox1 : TListBox;
Button1 : TButton;
Barre_des_tache : TTabControl;
Button2 : TButton;
Procedure Button1Click(Sender : TObject);
private
{ Déclarations privées }
public
{ Déclarations publiques }
End;
Var
Form1 : TForm1;
ClassName : Array[0..79] Of char;
str_TApplication,str_OleMa inThreadWn dClass, str_ClassName, str_DossierOuvert : String;
h_Process : integer;
Implementation
{$R *.DFM}
Function EnumWindowsCallBack(HWND : hwnd; LPARAM : lParam) : bool stdcall;
Var
capt : Array[0..79] Of char;
lpWndClass : TWndClassA;
tt, zz : variant;
Begin
zz := 0;
tt := 1;
result := true;
GetWindowText(HWND, capt, 79);
GetClassName(HWND, ClassName, 79);
GetClassInfo(HWND, ClassName, lpWndClass);
h_Process := FindWindow(ClassName, capt);
str_ClassName := ClassName;
str_DossierOuvert := 'CabinetWClass';
str_TApplication := 'TApplication';
str_OleMainThreadWndClass: ='OleMainT hreadWndCl ass';
If GetWindow(HWND, GW_OWNER)=zz Then
if GetParent(HWND)=zz then
If Length(capt) > 0 Then
if str_ClassName<>str_OleMain ThreadWndC lass then
Begin
Form1.Listbox1.items.add(c apt + ' ' + Classname + ' ' + IntToStr(hwnd) + ' ' + IntToStr(h_Process));
Form1.Barre_des_tache.Tabs .Add(capt) ;
End;
End;
Procedure TForm1.Button1Click(Sender : TObject);
Var
lpdevmode : tDeviceModeA;
security : tSecurityAttributes;
bureau : hdesk;
Begin
Form1.Barre_des_tache.Tabs .Clear;
Listbox1.Items.clear;
lpdevmode.dmSize := SIZEOF(tdevicemodea);
//lpdevmode.dmDisplayFrequ ency := 100;
//lpdevmode.dmPelsWidth:=1 024;
//lpdevmode.dmPelsHeight:= 768;
//lpdevmode.dmFields :=DM_PELSWIDTH + DM_PELSHEIGHT +DM_DISPLAYFREQUENCY;
security.nLength := sizeof(tsecurityattributes );
//security.lpSecurityDescr iptor:=a;
//security.bInheritHandle: =false;
bureau := createDesktop('Test',
'',
Nil, //@lpdevmode,
DF_ALLOWOTHERACCOUNTHOOK + DESKTOP_SWITCHDESKTOP, DESKTOP_ENUMERATE,
Nil); //@security);
// EnumDesktopWindows(bureau, @enumwindowscallback, 0);
//EnumThreadWindows(bureau ,@enumwind owscallbac k,0);
EnumWindows(@EnumWindowsCa llBack, 0);
End;
End.
////////////////////////// ////////// ////////// ////////// ////////
I tried the Madshi 's answer but I found again too much process.
ps:I'm on NT4 sp3.
//////////////////////////
Unit seb;
Interface
Uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComCtrls;
Type
TForm1 = Class(TForm)
ListBox1 : TListBox;
Button1 : TButton;
Barre_des_tache : TTabControl;
Button2 : TButton;
Procedure Button1Click(Sender : TObject);
private
{ Déclarations privées }
public
{ Déclarations publiques }
End;
Var
Form1 : TForm1;
ClassName : Array[0..79] Of char;
str_TApplication,str_OleMa
h_Process : integer;
Implementation
{$R *.DFM}
Function EnumWindowsCallBack(HWND : hwnd; LPARAM : lParam) : bool stdcall;
Var
capt : Array[0..79] Of char;
lpWndClass : TWndClassA;
tt, zz : variant;
Begin
zz := 0;
tt := 1;
result := true;
GetWindowText(HWND, capt, 79);
GetClassName(HWND, ClassName, 79);
GetClassInfo(HWND, ClassName, lpWndClass);
h_Process := FindWindow(ClassName, capt);
str_ClassName := ClassName;
str_DossierOuvert := 'CabinetWClass';
str_TApplication := 'TApplication';
str_OleMainThreadWndClass:
If GetWindow(HWND, GW_OWNER)=zz Then
if GetParent(HWND)=zz then
If Length(capt) > 0 Then
if str_ClassName<>str_OleMain
Begin
Form1.Listbox1.items.add(c
Form1.Barre_des_tache.Tabs
End;
End;
Procedure TForm1.Button1Click(Sender
Var
lpdevmode : tDeviceModeA;
security : tSecurityAttributes;
bureau : hdesk;
Begin
Form1.Barre_des_tache.Tabs
Listbox1.Items.clear;
lpdevmode.dmSize := SIZEOF(tdevicemodea);
//lpdevmode.dmDisplayFrequ
//lpdevmode.dmPelsWidth:=1
//lpdevmode.dmPelsHeight:=
//lpdevmode.dmFields :=DM_PELSWIDTH + DM_PELSHEIGHT +DM_DISPLAYFREQUENCY;
security.nLength := sizeof(tsecurityattributes
//security.lpSecurityDescr
//security.bInheritHandle:
bureau := createDesktop('Test',
'',
Nil, //@lpdevmode,
DF_ALLOWOTHERACCOUNTHOOK + DESKTOP_SWITCHDESKTOP, DESKTOP_ENUMERATE,
Nil); //@security);
// EnumDesktopWindows(bureau,
//EnumThreadWindows(bureau
EnumWindows(@EnumWindowsCa
End;
End.
//////////////////////////
Here is an example......
function GetTaskWindows(Handle : HWND; lparam : LPARAM) : Bool;stdcall;
var
Name : array[0..MAX_PATH] of char;
begin
if GetWindow(Handle, GW_CHILD) = 0 then begin
GetWindowText(Handle, Name, SizeOf(Name));
if StrPas(Name) <> '' then
Form1.ListBox1.Items.Add(N ame);
Result := True;
end;
end;
procedure TForm1.FormClick(Sender: TObject);
begin
EnumWindows(@GetTaskWindow s, 0);
end;
Regards,
Viktor Ivanov
function GetTaskWindows(Handle : HWND; lparam : LPARAM) : Bool;stdcall;
var
Name : array[0..MAX_PATH] of char;
begin
if GetWindow(Handle, GW_CHILD) = 0 then begin
GetWindowText(Handle, Name, SizeOf(Name));
if StrPas(Name) <> '' then
Form1.ListBox1.Items.Add(N
Result := True;
end;
end;
procedure TForm1.FormClick(Sender: TObject);
begin
EnumWindows(@GetTaskWindow
end;
Regards,
Viktor Ivanov
This is a better code actually....
function GetTaskWindows(Handle : HWND; lparam : LPARAM) : Bool;stdcall;
var
Name : array[0..MAX_PATH] of char;
begin
if GetParent(Handle) = 0 then begin
GetWindowText(Handle, Name, SizeOf(Name));
if StrPas(Name) <> '' then
Form1.ListBox1.Items.Add(N ame);
Result := True;
end;
end;
procedure TForm1.FormClick(Sender: TObject);
begin
EnumWindows(@GetTaskWindow s, 0);
end;
Regards,
Viktor Ivanov
function GetTaskWindows(Handle : HWND; lparam : LPARAM) : Bool;stdcall;
var
Name : array[0..MAX_PATH] of char;
begin
if GetParent(Handle) = 0 then begin
GetWindowText(Handle, Name, SizeOf(Name));
if StrPas(Name) <> '' then
Form1.ListBox1.Items.Add(N
Result := True;
end;
end;
procedure TForm1.FormClick(Sender: TObject);
begin
EnumWindows(@GetTaskWindow
end;
Regards,
Viktor Ivanov
Viktor, sorry, not complete... :-)
seb24, sorry, too. Have forgotten two things:
var taskWindows : string;
Function EnumWindowsCallBack(HWND : hwnd; LPARAM : lParam) : bool stdcall;
var s1 : string;
Begin
result:=true;
If (GetWindow(HWND,GW_OWNER)= 0) and (GetParent(HWND)=0) and IsWindowVisible(HWND) and
(GetWindowLong(HWND,GWL_EX STYLE) and WS_EX_TOOLWINDOW=0) then begin
SetLength(s1,MAX_PATH);
GetWindowText(HWND,pchar(s 1),MAX_PAT H);
s1:=string(pchar(s1));
If s1<>'' Then taskWindows:=taskWindows+s 1+#$D#$A;
end;
End;
begin
EnumWindows(@EnumWindowsCa llBack, 0);
MessageBox(0,pchar(taskWin dows),'Tas kWindows', 0);
end;
Regards, Madshi.
seb24, sorry, too. Have forgotten two things:
var taskWindows : string;
Function EnumWindowsCallBack(HWND : hwnd; LPARAM : lParam) : bool stdcall;
var s1 : string;
Begin
result:=true;
If (GetWindow(HWND,GW_OWNER)=
(GetWindowLong(HWND,GWL_EX
SetLength(s1,MAX_PATH);
GetWindowText(HWND,pchar(s
s1:=string(pchar(s1));
If s1<>'' Then taskWindows:=taskWindows+s
end;
End;
begin
EnumWindows(@EnumWindowsCa
MessageBox(0,pchar(taskWin
end;
Regards, Madshi.
Yup..Madshi has got the full procedure... Please reject ym answer and give 'im the points ;->
Regards,
Viktor Ivanov
Regards,
Viktor Ivanov
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
REGARDS,
(@VIKTOR_IVANOV)^.NAME;