Solved

Desktop icons into an imagelist. How?

Posted on 2004-10-01
5
1,039 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses
Course of the Month6 days, 11 hours left to enroll

636 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