这是一个获取文件图标的函数,其中就运用到了API函数。<br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, ShellAPI;<br>type<br> TForm1 = class(TForm)<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br> ShFileInfo: TSHFILEINFO;<br><br>implementation<br><br>{$R *.DFM}<br>function GetFileIconIndex(FileNameStr: string):integer;//获取图标的序号函数<br>var<br> ExtFile:String;<br>begin<br> ExtFile := FileNameStr;<br> Result := ShGetFileInfo(Pchar(ExtFile), 0, SHFileInfo,<br> SizeOf(SHFileInfo), SHGFI_LARGEICON or<br> SHGFI_SYSICONINDEX or SHGFI_TYPENAME);<br> Result:=SHFileInfo.iIcon;//图标序号<br>end;<br>