Solved

Desktop icons into an imagelist. How?

Posted on 2004-10-01
5
987 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now