News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

How do I get and use the ImageList used by the desktop listview

Started by jimg, February 28, 2013, 05:33:42 AM

Previous topic - Next topic

jimg

I'm trying to get icons from the desktop listview to use in my own listview.  The old method I learned from Donkey almost a decade ago no longer works in Windows 7.

Prior to Windows 7 (and maybe Vista?), the system stored the IDL in the lParam of the desktop listview.

.data?
IDL   dd 256 dup (?)
sfi SHFILEINFO <?>
.code
        ; after getting the lparam from the desktop listview using inv SendMessage, hListView, LVM_GETITEM, 0, SharedMem1
      inv ReadProcessMemory,hProcess1,objOut.lParam,addr IDL,1024,0 ; Copy the remote IDL into our local IDL
    inv SHGetFileInfo,addr IDL,0,addr sfi,SIZEOF SHFILEINFO,SHGFI_SYSICONINDEX+SHGFI_TYPENAME+SHGFI_PIDL+SHGFI_ICON
mov edx,sfi.iIcon     ; get the index into the system imagelist
mov lvi.iImage,edx  ; set the image in our listview


The new desktop returns zero in lParam.    In iImage, it returns what I suspect is the index into it's own imagelist, which is not the system imagelist.
The attached program is the program from the other thread with a listview added.  You can see all the information I was able to get from the desktop listview.  lParam is always zero.  iImage seems to be a sequential number starting with 8.

When you run the program, you will see that the image gotten from using iImage against the system imagelist in the leftmost column.  It clearly returns the incorrect icon.  I have also dumped all the system icons at the end of the same listview.  There is no obvious way to correlate the numbers.

I tried to get the actual handle of the imagelist the desktop listview is using like this:
    inv SendMessage,hdesklv, LVM_GETIMAGELIST,LVSIL_SMALL,0
    mov imagelist,eax   ; this doesn't give anything useful


I tried to use the handle returned to get a copy of the imagelist, to extract information from the image list, and anything else I could think of.   Every attempt at using the handle returned the invalid handle error.

Any suggestions anyone?  I'm looking for a simple straightforward answer that's valid for all the items on the desktop.  Stepping through the directory doesn't give all the desktop icons, and is not the type of thing I am looking for.



New three posts down.  This one deleted because of bug.

japheth


I run your program on XP SP3 (32-bit), and all lParams are 0 there, too. I expected your program to display "correct" values in a 32-bit OS. Did I miss something?

jimg

Drat.  I must have messed something up.  I'm visiting relatives for the next few day yet, and no one here has XP to test with.  I'll see if I can find it and get back.

jimg

I finally got virtual xp to work.  ugh.

So, by trial and error (could not find documentation to the fact), the problem turns out to be that if you ask for LVIF_COLUMNS, you won't get LVIF_PARAM.

I updated the program to use the SHGetFileInfo if the lParam is returned not zero.  Seems to work on XP now.  Still no good for Windows 7.

I had a problem with one icon on my virtual XP desktop, but it may have had something to do with being virtual.   Several of my icons will run programs right after dropping them on the virtual desktop, but when I start  up virtual XP later, they no longer work.