Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Desktop icons into an imagelist. How?

Posted on 2004-10-01
5
Medium Priority
?
1,067 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 300 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

972 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