# Windows : Retrive Quick Launch toolbar items

**URL:** <https://www.ruby-forum.com/t/windows-retrive-quick-launch-toolbar-items/163624>\
**Category:** Ruby\
**Created:** [March 23, 2009, 11:03am UTC](https://www.ruby-forum.com/t/windows-retrive-quick-launch-toolbar-items/163624 "2009-03-23T11:03:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ak3003](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/977dab/32.png) [@ak3003](https://www.ruby-forum.com/u/ak3003)\
**Post date:** [March 23, 2009, 11:03am UTC](https://www.ruby-forum.com/t/windows-retrive-quick-launch-toolbar-items/163624/1 "2009-03-23T11:03:22Z")

</div>

How can I get Quick Launch toolbar items, present in the explorer/  
desktop area? (Where you can see “Show Desktop” menu item)

Regards,  
–AK

---

<div class="post-metadata">

**Author:** ![ak3003](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/977dab/32.png) [@ak3003](https://www.ruby-forum.com/u/ak3003)\
**Post date:** [March 23, 2009, 11:33am UTC](https://www.ruby-forum.com/t/windows-retrive-quick-launch-toolbar-items/163624/2 "2009-03-23T11:33:31Z")

</div>

2009/3/23 Ak Newfish [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> How can I get Quick Launch toolbar items, present in the explorer/  
> desktop area? (Where you can see “Show Desktop” Â menu item)

puts Dir.entries(ENV[‘USERPROFILE’]+‘\Application  
Data\Microsoft\Internet Explorer\Quick Launch’)

Regards,

Park H.

---

<div class="post-metadata">

**Author:** ![ak3003](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/977dab/32.png) [@ak3003](https://www.ruby-forum.com/u/ak3003)\
**Post date:** [March 23, 2009, 12:07pm UTC](https://www.ruby-forum.com/t/windows-retrive-quick-launch-toolbar-items/163624/3 "2009-03-23T12:07:55Z")

</div>

Hi Park,

Thanks a ton! works fine.

I have another problem pops up on my way, should need to get the  
Notification area items (where you can see “volume control”), present in  
the explorer/desktop area.

How to get notification area items?

Regards,  
–AK.

---

<div class="post-metadata">

**Author:** ![ak3003](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/977dab/32.png) [@ak3003](https://www.ruby-forum.com/u/ak3003)\
**Post date:** [March 23, 2009, 4:21pm UTC](https://www.ruby-forum.com/t/windows-retrive-quick-launch-toolbar-items/163624/4 "2009-03-23T16:21:55Z")

</div>

Hi,

2009/3/23 Ak Newfish [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Hi Park,
> 
> Thanks a ton! works fine.
> 
> I have another problem pops up on my way, should need to get the  
> Notification area items (where you can see “volume control”), present in  
> the explorer/desktop area.
> 
> How to get notification area items?

If you mean system tray icons, that’s not easy as you think.  
Here is the code:

require ‘Win32API’

PROCESS\_QUERY\_INFORMATION = 1024  
PROCESS\_ALL\_ACCESS = 0x1F0FFF  
WM\_USER = 0x400  
TB\_BUTTONCOUNT = (WM\_USER+24)  
TB\_GETBUTTON = (WM\_USER+23)  
MEM\_COMMIT = 0x1000  
MEM\_RELEASE = 0x8000  
PAGE\_READWRITE = 0x4  
TBSTATE\_HIDDE = 0x8

FindWindow = Win32API.new(‘user32’, ‘FindWindow’, ‘PP’, ‘L’)  
FindWindowEx = Win32API.new(‘user32’, ‘FindWindowEx’, ‘LLPP’, ‘L’)  
SendMessage = Win32API.new(‘user32’, ‘SendMessage’, ‘LILL’, ‘L’)  
GetWindowThreadProcessId = Win32API.new(‘user32’,  
‘GetWindowThreadProcessId’, ‘LP’, ‘L’)  
OpenProcess = Win32API.new(‘kernel32’, ‘OpenProcess’, ‘LIL’, ‘L’)  
GetModuleFileNameEx = Win32API.new(‘psapi’, ‘GetModuleFileNameEx’,  
‘LLPL’, ‘L’)  
CloseHandle = Win32API.new(‘kernel32’, ‘CloseHandle’, ‘L’, ‘L’)  
ReadProcessMemory = Win32API.new(‘kernel32’, ‘ReadProcessMemory’,  
‘LLPLP’, ‘L’)  
VirtualAllocEx = Win32API.new(‘kernel32’, ‘VirtualAllocEx’, ‘LLLLL’,  
‘L’)  
VirtualFreeEx = Win32API.new(‘kernel32’, ‘VirtualFreeEx’, ‘LLL’, ‘L’)

def getProcessNameFromhWnd(dwhWnd)  
ppid = 0.chr \* 4  
GetWindowThreadProcessId.call(dwhWnd,ppid)  
pid = ppid.unpack(‘L’).first  
hProcess = OpenProcess.call(PROCESS\_ALL\_ACCESS, 0, pid)  
buffer = 0.chr \* 1024  
cbLen = GetModuleFileNameEx.call(hProcess, 0, buffer, buffer.length)  
CloseHandle.call(hProcess)  
buffer.strip  
end

# Get the tray window handle. ( Window XP).

hWindow = FindWindow.call(“Shell\_TrayWnd”, 0)  
hWindow = FindWindowEx.call(hWindow, 0, “TrayNotifyWnd”, 0)  
hWindow = FindWindowEx.call(hWindow, 0, “SysPager”, 0)  
hWindow = FindWindowEx.call(hWindow, 0, “ToolbarWindow32”, 0)

# Get the count of buttons in tray window.

trayCount = SendMessage.call(hWindow, TB\_BUTTONCOUNT, 0, 0)  
ppid = 0.chr \* 4  
GetWindowThreadProcessId.call(hWindow, ppid)  
pid = ppid.unpack(‘L’).first  
hProcess = OpenProcess.call(PROCESS\_ALL\_ACCESS, 0, pid)  
addr = VirtualAllocEx.call(hProcess, 0, 24, MEM\_COMMIT, PAGE\_READWRITE)  
for cb in 0 … trayCount  
tray = 0.chr \* 24  
tb = 0.chr \* 20  
SendMessage.call(hWindow,TB\_GETBUTTON,cb,addr)  
cbRead = 0.chr \* 4  
ReadProcessMemory.call(hProcess,addr,tb,tb.length,cbRead)  
fsState = tb[8,1].unpack(‘c’).first  
if fsState != TBSTATE\_HIDDE  
ReadProcessMemory.call(hProcess,tb[12,4].unpack(‘L’).first,tray,tray.length,cbRead)  
name = getProcessNameFromhWnd(tray[0,4].unpack(‘L’).first)  
puts name  
end  
end  
VirtualFreeEx.call(hProcess,addr,0,MEM\_RELEASE)  
CloseHandle.call(hProcess)

Regards,

Park H.

---

<div class="post-metadata">

**Author:** ![ak3003](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/977dab/32.png) [@ak3003](https://www.ruby-forum.com/u/ak3003)\
**Post date:** [March 24, 2009, 5:26am UTC](https://www.ruby-forum.com/t/windows-retrive-quick-launch-toolbar-items/163624/5 "2009-03-24T05:26:17Z")

</div>

Hi Park,

Thanks for your code! I mean for System tray icons and code worked like  
a fly 🙂

Thanks a ton for your help.

Regards,  
–AK
