I am creating a remote file manager. The server side application gets the list of drivers, directories and files in the computer, saves it as stream and send it to me in the current computer where I am. Everything works fine.
In the current computer, first I use the "OnCreate" event to fill a TListImage with shell icons (from the same current computer) and link it with the ListView where the file list will be showed. So, once received the list, I use this funcion below to show the generic file icon in the ListView:
function GetGenericFileIconIndex(Filename: string): Integer;
var
FInfo: TSHFileInfo;
begin
Result := -1;
if (SHGetFileInfo(PChar(Filename), FILE_ATTRIBUTE_NORMAL, FInfo, SizeOf(FInfo),
SHGFI_SYSICONINDEX or SHGFI_USEFILEATTRIBUTES) <> 0) then
Result := FInfo.iIcon;
end;
for I := 0 to Pred(List.Count) do
begin
Item := ListView.Items.Add;
Item.ImageIndex := GetGenericFileIconIndex(List[I]);
Item.Caption := List[I];
end;
With file name/extension I can get the correct shell icon, even in a different computer. But I also need to show the correct drive type icon. For example, on remote computer "D:" is a local fixed drive, but on current computer "D:" is a CD/DVD drive, so I cannot use the drive letter to get this icon. I need a way to get a "generic" drive type icon index from remote computer (fixed drive) and send it to the current computer.
For example, my goal is to obtain a default icon for a local hard dive, a default icon for a remote disk, a CD/DVD device and so on...
Sorry about mistakes, english is not my native language. I did my best to try to explain.
Maybe what I need is impossible, just let me know please...
Thanks!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…