// Get System Image List
procedure TfrmRemoteExplorer.GetSystemImageList;
var
SysImageList :uint; // temporary handle for System ImageLists
ShFileInfo :TShFileInfo; // Shell File Info structure
begin
lvFileList.LargeImages := TImageList.Create(self);
SysImageList := ShGetFileInfo('',0,ShFileInfo,SizeOf(ShFileInfo),
shgfi_SysIconIndex or shgfi_LargeIcon);
if SysImageList <> 0 then
begin
lvFileList.LargeImages.Handle := SysImageList;
lvFileList.LargeImages.ShareImages := true; // Avoid freeing of System Image List !
end;
lvFileList.SmallImages := TImageList.Create(self);
SysImageList := ShGetFileInfo('',0,ShFileInfo,SizeOf(ShFileInfo),shgfi_SysIconIndex or shgfi_SmallIcon);
if SysImageList <> 0 then
begin
lvFileList.SmallImages.Handle := SysImageList;
lvFileList.SmallImages.ShareImages := true; // Avoid freeing of System Image List !
end;
end;
function GetImageIndex(Filename: String): Integer;
var
Fileinfo: TSHFileInfo;
begin
if SHGetFileInfo(PChar(FileName), 0, Fileinfo, sizeof(TSHFileInfo),
SHGFI_ICON or SHGFI_SYSICONINDEX or SHGFI_USEFILEATTRIBUTES) <> 0 then
begin
Result := Fileinfo.IIcon;
end else Result := 0;
end;
procedure TfrmRemoteExplorer.DisplayFileList;
var
List, CommaList: TStringList;
I, DirCnt, FileCnt: Integer;
Item: TListItem;
f: Single;
begin
List:= TStringList.Create;
CommaList:= TStringList.Create;
List.Text:= FFileList;
DirCnt:= 0;
FileCnt:= 0;
lvFileList.Items.Clear;
lvFileList.Items.BeginUpdate;
for I:= 0 to List.Count - 1 do
begin
CommaList.CommaText:= List[I];
Item:= lvFileList.Items.Add;
if CommaList.Count < 4 then
begin
Item.Caption:= CommaList.Text;
Continue;
end;
Item.Caption:= CommaList[0];
f:= StrToFloat(CommaList[1]);
Item.SubItems.Add(FormatFloat('#,0', f));
Item.SubItems.Add(CommaList[2]);
Item.SubItems.Add(CommaList[3]);
if CommaList[3] = 'dir' then
begin
Item.ImageIndex:= DirShellInfo.iIcon;
Inc(DirCnt);
end
else
begin
Item.ImageIndex:= GetImageIndex(Item.Caption);
Inc(FileCnt);
end;
end;
StatusBar1.SimpleText:= Format('[디렉토리 : %d개] / [파일 : %d개]', [DirCnt, FileCnt]);
lvFileList.Items.EndUpdate;
lvFileList.CustomSort(@CustomSortProc,2);
List.Free;
CommaList.Free;
end;
// Get System Image List
procedure TfrmRemoteExplorer.GetSystemImageList;
var
SysImageList :uint; // temporary handle for System ImageLists
ShFileInfo :TShFileInfo; // Shell File Info structure
begin
lvFileList.LargeImages := TImageList.Create(self);
SysImageList := ShGetFileInfo('',0,ShFileInfo,SizeOf(ShFileInfo),
shgfi_SysIconIndex or shgfi_LargeIcon);
if SysImageList <> 0 then
begin
lvFileList.LargeImages.Handle := SysImageList;
lvFileList.LargeImages.ShareImages := true; // Avoid freeing of System Image List !
end;
lvFileList.SmallImages := TImageList.Create(self);
SysImageList := ShGetFileInfo('',0,ShFileInfo,SizeOf(ShFileInfo),shgfi_SysIconIndex or shgfi_SmallIcon);
if SysImageList <> 0 then
begin
lvFileList.SmallImages.Handle := SysImageList;
lvFileList.SmallImages.ShareImages := true; // Avoid freeing of System Image List !
end;
end;
function GetImageIndex(Filename: String): Integer;
var
Fileinfo: TSHFileInfo;
begin
if SHGetFileInfo(PChar(FileName), 0, Fileinfo, sizeof(TSHFileInfo),
SHGFI_ICON or SHGFI_SYSICONINDEX or SHGFI_USEFILEATTRIBUTES) <> 0 then
begin
Result := Fileinfo.IIcon;
end else Result := 0;
end;
procedure TfrmRemoteExplorer.DisplayFileList;
var
List, CommaList: TStringList;
I, DirCnt, FileCnt: Integer;
Item: TListItem;
f: Single;
begin
List:= TStringList.Create;
CommaList:= TStringList.Create;
List.Text:= FFileList;
DirCnt:= 0;
FileCnt:= 0;
lvFileList.Items.Clear;
lvFileList.Items.BeginUpdate;
for I:= 0 to List.Count - 1 do
begin
CommaList.CommaText:= List[I];
Item:= lvFileList.Items.Add;
if CommaList.Count < 4 then
begin
Item.Caption:= CommaList.Text;
Continue;
end;
Item.Caption:= CommaList[0];
f:= StrToFloat(CommaList[1]);
Item.SubItems.Add(FormatFloat('#,0', f));
Item.SubItems.Add(CommaList[2]);
Item.SubItems.Add(CommaList[3]);
if CommaList[3] = 'dir' then
begin
Item.ImageIndex:= DirShellInfo.iIcon;
Inc(DirCnt);
end
else
begin
Item.ImageIndex:= GetImageIndex(Item.Caption);
Inc(FileCnt);
end;
end;
StatusBar1.SimpleText:= Format('[디렉토리 : %d개] / [파일 : %d개]', [DirCnt, FileCnt]);
lvFileList.Items.EndUpdate;
lvFileList.CustomSort(@CustomSortProc,2);
List.Free;
CommaList.Free;
end;