Solved

Desktop icons into an imagelist. How?

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

930 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

8 Experts available now in Live!

Get 1:1 Help Now