Solved

Desktop icons into an imagelist. How?

Posted on 2004-10-01
5
1,005 Views
Last Modified: 2007-12-19
Hi all!

How can i read desktop icons into an imagelist?

Desktop icons are in a syslistview32:

h:=FindWindow('Progman', nil);
h:=FindWindowEx(h,hwnd(0),'SHELLDLL_DefView',nil);
h:=FindWindowEx(h,hwnd(0),'SysListView32',nil);

My attempts using ListView_GetImageList... and SendMessage(h,LVM_GETIMAGELIST,LVSIL_NORMAL,0) are unsuccessful.

I don't want to read \Desktop directories to resolve my problem.

Thanks!
0
Comment
Question by:rogerrr
  • 2
  • 2
5 Comments
 
LVL 12

Accepted Solution

by:
Lee_Nover earned 100 total points
ID: 12206734
this small example get's the system imagelist and the desktops icons :)
note that no checking is done for sake of brevity :P (and my lazines)


uses ShellAPI, ShlObj;

procedure TForm1.FormCreate(Sender: TObject);
var sfi: TSHFileInfo;
    item: PItemIDList;
    sdf: IShellFolder;
    idlist: IEnumIDList;
    fetched: Cardinal;
begin
     ZeroMemory(@sfi, SizeOf(sfi));
     ImageList1.Handle:=SHGetFileInfo(PChar(ParamStr(0)), 0, sfi, SizeOf(sfi),
       SHGFI_ICON or SHGFI_LARGEICON or SHGFI_SYSICONINDEX); // large icons
     ImageList1.ShareImages:=true; // so you don't destroy the system imagelist

     SHGetDesktopFolder(sdf);
     sdf.EnumObjects(0, SHCONTF_FOLDERS or SHCONTF_NONFOLDERS, idlist);
     while Succeeded(idlist.Next(1, item, fetched)) do
     begin
       if fetched = 0 then exit;
       SHGetFileInfo(PChar(item), 0, sfi, SizeOf(sfi), // get the icon index and display name
         SHGFI_PIDL or SHGFI_DISPLAYNAME or SHGFI_ICON or SHGFI_LARGEICON or SHGFI_SYSICONINDEX);

       with ListView1.Items.Add do
       begin
         Caption:=sfi.szDisplayName;
         ImageIndex:=sfi.iIcon;
       end;
     end;
end;
0
 

Author Comment

by:rogerrr
ID: 12207222
Thank you!
0
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 12207919
and why the B grade ?!?!?!!?
ugh !
0
 

Author Comment

by:rogerrr
ID: 12237378
Sorry, i made a mistake. :-(
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 12237476
rogerrr, you can let a comment ( 0 points) into Community Support and ask to change for you the grade, from B to A ( let there the link to this topic ) . Not cost you additional points :)
0

Featured Post

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question