Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi How to enumerate all trayicons in the taskbar (https://www.delphipraxis.net/128651-how-enumerate-all-trayicons-taskbar.html)

Razor 3. Feb 2009 14:24


How to enumerate all trayicons in the taskbar
 
I asked this several times here on forum,is english the problem,you dont like me ?What is it?

I ask if its possible to get the icons that you see in your taskbar enumerated in a form??To get that in a form so you can interact with it?

Uwe Raabe 3. Feb 2009 14:36

Re: Enumerate all icons in a panel?
 
If you don't get any answer it is best to clarify your question. It is most likely as no one can understand your question (not because its English) as no one likes you.

For example: the title says something "Enuemaret all icons in a panel" but in your question you mention icons in the taskbar. This may irritate some people.

As the taskbar usually contains tasks instead of icons (the icons are only a visible hint to the task), your question can be read: How to enumerate all tasks in the taskbar?

Try that and see what happens.

Razor 3. Feb 2009 14:42

Re: How to enumerate all trayicons in the taskbar
 
Basicly what i want to do is take all icons from Traynotifywnd and then show it in a form or panel,ive tried so many diffrent aproaches that i got sick of it quickly.

Uwe Raabe 3. Feb 2009 14:49

Re: How to enumerate all trayicons in the taskbar
 
Have a look at madcollection. In madkernel.pas ther is an interface ITrayICons that let you iterate over all trayicons. Ther is a charge of $99 for commercial use and source code, though. But what you get is worth so much more.

Razor 3. Feb 2009 14:49

Re: How to enumerate all trayicons in the taskbar
 
I've tried this and it won't work in vista x64...Hook won't work.
Thanks though..

Tyrael Y. 3. Feb 2009 14:55

Re: How to enumerate all trayicons in the taskbar
 
Sorry im confused.

Do you really want only the icons, which you can see in the tray or
do you want the icons AND the process which belongs to the specific icon
and have control through it from your application?

Razor 3. Feb 2009 15:00

Re: How to enumerate all trayicons in the taskbar
 
i want complete tray funcionality on my form.Every icon that you see in tray

Tyrael Y. 3. Feb 2009 15:04

Re: How to enumerate all trayicons in the taskbar
 
Perhaps this helps...i know only there was a discussion and sourceCode to get all TrayProcesses...i didn´t tried if its work.

here

Razor 3. Feb 2009 16:06

Re: How to enumerate all trayicons in the taskbar
 
I will test it and thanks also!

Phoenix 3. Feb 2009 16:56

Re: How to enumerate all trayicons in the taskbar
 
Zitat:

Zitat von Razor
I've tried this and it won't work in vista x64...Hook won't work.
Thanks though..

It is impossible for that to work on a x64 system (neither XP x64 nor vista). You simply can't create 64bit dll's with Delphi. You need to wait for the x64 compiler (coming approx. end of 2009, middle 2010) or write this in another language that can emit x64 code.

Razor 3. Feb 2009 17:31

Re: How to enumerate all trayicons in the taskbar
 
Zitat:

Zitat von Tyrael Y.
Perhaps this helps...i know only there was a discussion and sourceCode to get all TrayProcesses...i didn´t tried if its work.

here


Can somebody test this on vista for me it won't work.

Razor 4. Feb 2009 14:58

Re: How to enumerate all trayicons in the taskbar
 
Now i have to install 32 bit version of vista just becouse of delphi :x .Is there really no other way?

nuclearping 4. Feb 2009 15:02

Re: How to enumerate all trayicons in the taskbar
 
Don't use Delphi then, because Delphi can't compile 64bit modules, which are required for hooks in a 64bit environment, no matter if XP or Vista.

This statement was already made here in this thread. --> http://www.delphipraxis.net/internal...=997247#997247

Razor 4. Feb 2009 15:03

Re: How to enumerate all trayicons in the taskbar
 
But if we talk wich Language is the easiest i would say its delphi.So yea ill go to vista 32.

nuclearping 4. Feb 2009 15:05

Re: How to enumerate all trayicons in the taskbar
 
Depends on what you want to make. If you use Windows API then it really doesn't matter if you use Delphi or C++. There are the language differences, but the API calls are almost the same.

Razor 4. Feb 2009 15:14

Re: How to enumerate all trayicons in the taskbar
 
I won't reformat the solution is in virtualization. :-D

Razor 6. Feb 2009 19:52

Re: How to enumerate all trayicons in the taskbar
 
I got an idea what if i make the dll that contains everything to enumerate the tray in Lazerous 64 bit.Then call it from delphi 2009 would this work!

mr_emre_d 8. Feb 2009 08:42

Re: How to enumerate all trayicons in the taskbar
 
why don't you use the predefined messages ?

just try to get the informations by sending

--"TB_BUTTONCOUNT" (-> tells you how many "buttons" there are)
--"TB_GETBUTTON" (-> moves the information to the allocated memory in the same process)

to

Shell_TrayWnd .-> TrayNotifyWnd .-> SysPager .-> ToolbarWindow32

:P

mr_emre_d 8. Feb 2009 13:32

Re: How to enumerate all trayicons in the taskbar
 
Liste der Anhänge anzeigen (Anzahl: 2)
A demo application :)

( i used some code - snippets which i got from Jonas [thx ;)] )

Meflin 8. Feb 2009 14:17

Re: How to enumerate all trayicons in the taskbar
 
Zitat:

Zitat von mr_emre_d
A demo application :)

Doesn't work here (Vista 64 Bit) :(

mr_emre_d 8. Feb 2009 14:19

Re: How to enumerate all trayicons in the taskbar
 
:S

Im using the 32 bit system and it works fine ...

:gruebel:

Meflin 8. Feb 2009 14:25

Re: How to enumerate all trayicons in the taskbar
 
Zitat:

Zitat von mr_emre_d
Im using the 32 bit system and it works fine ...

Maybe you could post a screenshot, but here on my pc it just shows a blank form with a "G", and i guess that's not what its supposed to be ;)

mr_emre_d 8. Feb 2009 14:41

Re: How to enumerate all trayicons in the taskbar
 
ive just edited my previous post :)

Ok the current one (that ive just uploaded) should work on 64 bit systems..

Meflin 8. Feb 2009 15:07

Re: How to enumerate all trayicons in the taskbar
 
No, still doesn't work. Now I see four empty rectangles, but I have five two icons in the TNA and the icons aren't displayed anyway.

mr_emre_d 8. Feb 2009 15:14

Re: How to enumerate all trayicons in the taskbar
 
:S

i have no idea why it does not work on 64 bit sys.

yeah i know that problem :)

e.g if i open the xplorer i cann see 7 entries in my program ..

here is the code if someone needs it :)

Delphi-Quellcode:
//types
type
  TTBBUTTON = packed record   // 20
    iBitmap: Integer;
    idCommand: Integer;
    fsState: Byte;
    fsStyle: Byte;
    bReserved: array[1..2] of Byte;
    dwData: Longint;
    iString: Integer;
  end;

  PTNAEntry = ^TTNAEntry;
  TTNAEntry = record
    hwnd: Cardinal;
    uID: Integer;
    uCallbackMessage: Cardinal;
    Unknwon1: Array[0..1] of Cardinal;
    hIcon: Cardinal;
    Unknwon2: Array[0..2] of Cardinal;
    uniPath: string;
    sTip: string;
    iBitmap: Cardinal;
    idCommand: Integer;
    fsState: byte;
    fsStyle: byte;
    dwData: Cardinal;
    iString: Cardinal;
  end;
  TTNAEntryArr = Array of TTNAEntry;
// funcs
function GetTNAEntries(): TTNAEntryArr;
var
  but: TTBBUTTON;
  hWnd, PID,
  hProc: Cardinal;
  MEM: Pointer;
  Count: Cardinal;
  x: Cardinal;
  i: Integer;
  buf: WideChar;
  p: PWideChar;
const
  TB_GETBUTTON  = WM_USER+$17; //23;
  TB_BUTTONCOUNT = WM_USER+$18; //24;
begin
  hWnd := FindWindowEx( FindWindowEx( FindWindowEx( FindWindow('Shell_TrayWnd',0), 0, 'TrayNotifyWnd', 0 ), 0, 'SysPager', 0 ), 0, 'ToolbarWindow32', 0 );
  GetWindowThreadProcessID( hWnd, @PID );
  try
    hProc := OpenProcess( PROCESS_ALL_ACCESS, False, PID );
    MEM  := VirtualAllocEx( hProc, nil, SizeOf(TTBButton), MEM_COMMIT, PAGE_EXECUTE_READWRITE );
    Count := SendMessage( hWnd, TB_BUTTONCOUNT, 0, 0 );
    SetLength(Result, Count);
    for i := 0 to Count - 1 do
    begin
      SendMessage( hWnd, TB_GETBUTTON, i, integer(MEM) );
      ReadProcessMemory( hProc, MEM, @but, SizeOf(TTBBUTTON), x );
      Move( but, Result[i].hwnd, sizeof(but) );
      if but.iString > 0 then
      begin
        p := Pointer(but.iString);
        repeat
          ReadProcessMemory( hProc, p, @buf, 2, x );
          inc(p);
          Result[i].sTip := Result[i].sTip + buf;
        until buf = #0;
      end;
      ReadProcessMemory( hProc, Pointer(but.dwData), @result[i].hwnd, 36, x );
    end;
  finally
    VirtualFreeEx( hProc, MEM, SizeOf(TTBButton), MEM_DECOMMIT );
    CloseHandle( hProc );
  end;
end;
(btw. thanks jonas - again :P)

DerCarsten 26. Feb 2011 18:47

AW: How to enumerate all trayicons in the taskbar
 
Hi,

auch wenn es schon eine Weile her ist. Der Grund, warum es nicht auf 64bit funktioniert ist:

Code:
typedef struct _TBBUTTON {
    int        iBitmap;
    int        idCommand;
    BYTE    fsState;
    BYTE    fsStyle;
#ifdef _WIN64
    BYTE    bReserved[6]    // padding for alignment
#elif defined(_WIN32)
    BYTE    bReserved[2]    // padding for alignment
#endif
    DWORD_PTR  dwData;
    INT_PTR         iString;
} TBBUTTON, NEAR *PTBBUTTON *LPTBBUTTON;
Ist zwar C++ Code, es sollte aber dennoch gut ersichtlich sein, daß die Struktur unter 64bit geringfügig anders ist. Die Struktur Deines Codes ist statisch und berücksichtigt das nicht. :thumb:


Oops, English required... :-)

The structure on 64bit systems is slightly different (bigger). The structure you're using is static and does not consider the 64bit variant.

Regards,

Carsten


Alle Zeitangaben in WEZ +1. Es ist jetzt 13:59 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz