本例實現將打開對話框中選擇的文件的圖標和文件名顯示在ListView中
http://develop
圖
通過SHGetFileInfo方法獲取文件的圖標
//單擊
procedure TForm
var ListItem: TListItem;
Flag: Cardinal;
info: SHFILEINFOA;
Icon: TIcon;
OpenDiaLog: TOpenDialog;
begin
OpenDiaLog := TOpenDialog
if OpenDiaLog
begin
with ListView
begin
LargeImages := ImageList
Icon := TIcon
ListItem := Items
Listitem
Flag := (SHGFI_SMALLICON or SHGFI_ICON or SHGFI_USEFILEATTRIBUTES);
SHGetFileInfo(Pchar(OpenDiaLog
Icon
ImageList
ListItem
end;
end;
end;
//雙擊ListView
procedure TForm
var FileName: string;
os: OFSTRUCT;
hFile: THandle;
begin
FileName := ListView
ShellExecute(self
end;
From:http://tw.wingwit.com/Article/program/Delphi/201311/8498.html