AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Win32/Win64 API (native code) Delphi How to enumerate all trayicons in the taskbar
Thema durchsuchen
Ansicht
Themen-Optionen

How to enumerate all trayicons in the taskbar

Ein Thema von Razor · begonnen am 3. Feb 2009 · letzter Beitrag vom 26. Feb 2011
Antwort Antwort
Seite 3 von 3     123   
mr_emre_d
(Gast)

n/a Beiträge
 
#21

Re: How to enumerate all trayicons in the taskbar

  Alt 8. Feb 2009, 14:19
:S

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

  Mit Zitat antworten Zitat
Benutzerbild von Meflin
Meflin

Registriert seit: 21. Aug 2003
4.856 Beiträge
 
#22

Re: How to enumerate all trayicons in the taskbar

  Alt 8. Feb 2009, 14:25
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
  Mit Zitat antworten Zitat
mr_emre_d
(Gast)

n/a Beiträge
 
#23

Re: How to enumerate all trayicons in the taskbar

  Alt 8. Feb 2009, 14:41
ive just edited my previous post

Ok the current one (that ive just uploaded) should work on 64 bit systems..
  Mit Zitat antworten Zitat
Benutzerbild von Meflin
Meflin

Registriert seit: 21. Aug 2003
4.856 Beiträge
 
#24

Re: How to enumerate all trayicons in the taskbar

  Alt 8. Feb 2009, 15:07
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.
  Mit Zitat antworten Zitat
mr_emre_d
(Gast)

n/a Beiträge
 
#25

Re: How to enumerate all trayicons in the taskbar

  Alt 8. Feb 2009, 15:14
: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 )
  Mit Zitat antworten Zitat
DerCarsten

Registriert seit: 26. Feb 2011
1 Beiträge
 
#26

AW: How to enumerate all trayicons in the taskbar

  Alt 26. Feb 2011, 18:47
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.


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

Geändert von DerCarsten (26. Feb 2011 um 18:50 Uhr)
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 3 von 3     123   


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 02:09 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz