Problem Source: http://www.cnblogs.com/del/archive/2008/12/30/1364557.html#1417716
In this example:
Code File:
Unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, stdctrls, comctrls; Type tform1 = Class (tform) button1: tbutton; button2: tbutton; button3: tbutton; listview1: tlistview; Procedure upload (Sender: tobject); Procedure button3click (Sender: tobject); end; var form1: tform1; implementation {$ R *. DFM} uses commctrl; {function for obtaining the tray handle} function trayhwnd: hwnd; var H, htmp: hwnd; begin H: = findwindow ('Shell _ traywnd ', nil ); h: = find1_wex (H, 0, 'traypolicywnd', nil); htmp: = find1_wex (H, 0, 'syspager ', nil); If htmp 0 then h: = htmp; htmp: = find1_wex (H, 0, 'toolbarwindow32', nil); If htmp 0 Then H: = htmp; Result: = H; end; {control initialization} procedure tform1.formcreate (Sender: tobject); begin listview1.align: = alleft; listview1.columns. add; listview1.columns. items [0]. caption: = 'tray icon list'; listview1.columns. items [0]. width: = 500; listview1.viewstyle: = vsreport; button1.caption: = 'display tray list'; button2.caption: = 'hide all '; button3.caption: = 'unhide'; button2.enabled: = false; button3.enabled: = false; end; {extraction list} procedure tform1.button1click (Sender: tobject); var H: hwnd; count, size, num: Cardinal; PID, pH: Cardinal; P: pointer; icobtn: ttbbutton; Buf: array [0 .. 255] of widechar; I: integer; item: tlistitem; begin H: = trayhwnd; count: = sendmessage (H, tb_buttoncount, 0, 0); Size: = sizeof (ttbbutton); getwindowthreadprocessid (H, pid); Ph: = OpenProcess (process_vm_read, false, pid); for I: = 0 to count-1 do begin sendmessage (H, tb_getbutton, I, DWORD (p); readprocessmemory (pH, P, @ icobtn, size, num); readprocessmemory (pH, pointer (icobtn. istring), @ Buf, length (BUF) * sizeof (BUF [0]), num); item: = listview1.items. add; item. caption: = Buf; end; closehandle (ph); button2.enabled: = true; button3.enabled: = true; end; {hide all} procedure tform1.button2click (Sender: tobject); var h: hwnd; count, I: Cardinal; begin H: = trayhwnd; count: = sendmessage (H, tb_buttoncount, 0, 0); for I: = 0 to count-1 do sendmessage (H, tb_hidebutton, I, 1); end; {show all} procedure tform1.button3click (Sender: tobject); var H: hwnd; count, i: Cardinal; begin H: = trayhwnd; count: = sendmessage (H, tb_buttoncount, 0, 0); for I: = 0 to count-1 do sendmessage (H, tb_hidebutton, i, 0); end.
Form file:
Object form1: tform1 left = 0 Top = 0 caption = 'form1' clientheight = 142 clientwidth = 300 color = clbtnface font. charset = default_charset font. color = clwindowtext font. height =-11 font. name = 'tahoma 'font. style = [] oldcreateorder = false oncreate = formcreate pixelsperinch = 96 textheight = 13 object button1: tbutton left = 182 Top = 14 width = 106 Height = 25 caption = 'button1' taborder = 0 onclick = button1click end object listview1: tlistview left = 8 Top = 8 width = 169 Height = 119 columns = taborder = 1 end object button2: tbutton left = 182 Top = 59 width = 106 Height = 25 caption = 'button2' taborder = 2 onclick = button2click end object button3: tbutton left = 182 Top = 102 width = 106 Height = 25 caption = 'button3' taborder = 3 onclick = button3click endend