Using the system image list

If you've ever required access to the WIN95 System image list for your list
view, here it is. The first function retrieves an INDEX into the system
image list for a particular file 'type':

     function GetFileIcoIndex(Filename:String):Integer;
     var
       Ext: String;
       ShFileInfo: TSHFILEINFO;
     begin
       Ext := filename;
       ShGetFileInfo(PChar(Ext), 0, SHFileInfo, SizeOf(SHFileInfo),
             SHGFI_SMALLICON or SHGFI_SYSICONINDEX or SHGFI_TYPENAME);
       result:= SHFileInfo.iIcon;
     end;

Here we tie the system image list to our list view control. Please note
that we set the ShareImages property of the dynamically created image list
to TRUE. This ensures we don't attempt to free images owned by Windows.
Next, we add the following to our form.OnCreate event:

      with YourListView do
       begin
         SmallImages := TImageList.CreateSize(16,16);
         SmallImages.ShareImages := True;
         SmallImages.Handle := ShGetFileInfo('*.*', 0, SHFileInfo,
           SizeOf(SHFileInfo), SHGFI_SMALLICON or SHGFI_ICON or
SHGFI_SYSICONINDEX);
         LargeImages := TImageList.Create(nil);
         LargeImages.ShareImages := True;
         LargeImages.Handle := ShGetFileInfo('*.*', 0, SHFileInfo,
           SizeOf(SHFileInfo), SHGFI_LARGEICON or SHGFI_ICON or
SHGFI_SYSICONINDEX);
       end;

Then add these lines in the form.OnDestroy:

       YourListView.SmallImages.Free;
       YourListView.LargeImages.Free;