// Declaration: extracticon (hinst: hinst; {call the function's Program Instance} lpszexefilename: pchar; {file path; file may be *. EXE ,*. DLL ,*. ICO} niconindex: uint {icon index}): hicon; {return icon handle; returns the first icon handle when the index is 0; returns the total number of icons when the index is # ffffffff}
// Example: Unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, stdctrls, extctrls; Type tform1 = Class (tform) button1: tbutton; Procedure button1click (Sender: tobject); end; var form1: tform1; implementation {$ R *. DFM} uses shellapi; {extracticon declares in it} procedure tform1.button1click (Sender: tobject); var ICO: ticon; I, Count, X, Y, W, H: integer; filepath: string; begin {any path is found. If it is missing, it will exit.} filepath: = 'C: \ Program Files \ Macromedia \ fireworks 8 \ fireworks.exe '; if not fileexists (filepath) then begin showmessage ('file does not exist'); exit; end; ICO: = ticon. create; X: = 10; Y: = 10; W: = 0; H: = 0; repaint; {calculate the total number of icons in the file first} count: = extracticon (hinstance, pchar (filepath), hicon (-1); for I: = 0 to count-1 do begin {loop extraction icon} ico. handle: = extracticon (hinstance, pchar (filepath), I); {draw icon} canvas. draw (X, Y, ico); {The following is just to adjust the display position} If W = clientwidth-W then begin X: = 10; Y: = Y + H + 10; end; end; ICO. free; end.
//: