Hi Rogerrr,
Ive uploaded an example for you, (rename jpg to rar) i hope it is what you want :
//Using Russels units and code.
Main Topics
Browse All TopicsHello!
I'd like to make an application with i can enumerate all icons (with tips) from the system tray. I tried to make this, and now i can retrieve the names of processes, but not more. Some days ago i did found a VB code that's working in Delphi too.
type
Tray=record
hwnd: HWND;
uID: UINT;
uCallbackMessage: UINT;
Reserved1: array[0..1] of longint;
Reserved2: array[0..2] of longint;
hIcon: HICON;
end;
_TBBUTTON64 = packed record
iBitmap: Integer;
idCommand: Integer;
fsState: Byte;
fsStyle: Byte;
Padding1: Byte;
Padding2: Byte;
Padding3: Byte;
Padding4: Byte;
Padding5: Byte;
Padding6: Byte;
dwData: Longint;
iString: Integer;
end;
procedure TForm1.Button1Click(Sender
var
hProc: THandle;
hWindow: Hwnd;
lppid: UINT;
lpPointer: ^pointer;
ret: dword;
tb64: _TBBUTTON64;
dwIndex: integer;
dwCount: integer;
lphwnd: Hwnd;
begin
ListBox1.Clear;
hWindow:=FindWindow('Shell
hWindow:=FindWindowEx(hWin
hWindow:=FindWindowEx(hWin
hWindow:=FindWindowEx(hWin
dwCount:=SendMessage(hWind
GetWindowThreadProcessId(h
hProc:=OpenProcess(PROCESS
lpPointer:=VirtualAllocEx(
for dwIndex:=0 to dwCount-1 do
begin
SendMessage(hWindow,TB_GET
ReadProcessMemory(hProc,lp
if tb64.dwData<>0 then
begin
ReadProcessMemory(hProc,PC
ListBox1.Items.Add(GetProc
end;
end;
VirtualFreeEx(hProc,lpPoin
CloseHandle(hProc);
end;
##########################
Today i searched the Net and i found an another code that's able to enumerate all icons, tips from systray and compatible with x64 systems too.
It tested on Windows 2000, XP, Vista 32-bit and Windows 7 64-bit noted in the article description. I examined this code and i didn't find any unknown function for Delphi (to my mind) but i don't know how can i realize it under Delphi. Is there any way to change this code to Delphi and can be compatible with x64 too?
http://www.quickmacros.com
function hwnd ARRAY(TRAYICONINFO)&a mask ;;mask: 1 get tooltip, 2 get hwnd, hicon, callbackMsg, callbackId
//hwnd - tray toolbar control handle. If 0, the function tries to find the control.
//a - receives each icon info:
//tooltip - tooltip text.
//hidden - 0 if the icon is visible, 1 if hidden.
//idCommand - toolbar control button id.
//hwnd - handle of window that added the icon.
//hicon - icon handle.
//callbackMsg, .callbackId - on mouse and other events the window receives this message with this id.
//mask - must be 3 to get all info. If some info not needed, use 0, 1 or 2. It will make faster.
//EXAMPLE
//out
//#compile "__TRAYICONINFO"
//ARRAY(TRAYICONINFO) a
//EnumTrayIcons 0 a 3
//int i
//for i 0 a.len
//TRAYICONINFO& r=a[i]
//if(r.hidden) continue
//RecGetWindowName r.hwnd &_s
//out "tt='%s' idcmd=%i window=%s hicon=%i callbackId=%i callbackMsg=%i" r.tooltip r.idCommand _s r.hicon r.callbackId r.callbackMsg
type __SHTRAYICON hwnd callbackId callbackMsg unknown[2] hIcon
type __SHTRAYICON64 %hwnd callbackId callbackMsg unknown[2] %hIcon
type TBBUTTON64 iBitmap idCommand !fsState !fsStyle !bReserved[6] %dwData %iString
a=0
if(!hwnd) hwnd=child("" "ToolbarWindow32" "+Shell_TrayWnd" 0x1); if(!hwnd) end ES_WINDOW
int i n=SendMessage(hwnd TB_BUTTONCOUNT 0 0)
if(!n) ret
lock _share
TBBUTTON* bq=share
TBBUTTON* be=share(hwnd)
word* tq=bq+sizeof(TBBUTTON64)
word* te=be+sizeof(TBBUTTON64)
if(mask&2)
,GetWindowThreadProcessId(
,__Handle hp=OpenProcess(PROCESS_VM_
for i 0 n
,if(!SendMessage(hwnd TB_GETBUTTON i be)) continue
,TRAYICONINFO& ti=a[]
,ti.hidden=bq.fsState&TBST
,ti.idCommand=bq.idCommand
,if(mask&1)
,,_i=SendMessage(hwnd TB_GETBUTTONTEXTW bq.idCommand 0)
,,if(_i<0 or _i>450 or SendMessage(hwnd TB_GETBUTTONTEXTW bq.idCommand te)<0) tq[0]=0
,,ti.tooltip.ansi(tq)
,if(mask&2)
,,if(!_win64)
,,,__SHTRAYICON sti
,,,if(ReadProcessMemory(hp
,,,,ti.callbackId=sti.call
,,,,ti.callbackMsg=sti.cal
,,,,ti.hicon=sti.hIcon
,,,,ti.hwnd=sti.hwnd
,,else
,,,__SHTRAYICON64 sti64
,,,if(ReadProcessMemory(hp
,,,,ti.callbackId=sti64.ca
,,,,ti.callbackMsg=sti64.c
,,,,ti.hicon=sti64.hIcon
,,,,ti.hwnd=sti64.hwnd
Please share source too, if you can help me!
Thanks in advance!
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Here is a source of the same thing in C.
Business Accounts
Answer for Membership
by: EddieShipmanPosted on 2009-08-12 at 13:33:58ID: 25082626
If I'm not mistaken, Madshi's madKernel package has some code that worked on systray icons. Visit his site to see if it's still there.
yIcons.htm
See this: http://help.madshi.net/Tra