Click to See Complete Forum and Search --> : Simple way to get desktop items


aewarnick
April 25th, 2005, 08:21 PM
Is there a simple api call I could use to get all the items from the desktop. I'm making a custom file browser.

I know I could do a switch for the users system and user name(XP) and get the items from their respective directories, but I was just wondering if there was a better way.

Quell
April 25th, 2005, 08:56 PM
Desktop is a listview control, just get all the stuff in all the boxes.....i think it is listview....
don;'t take my word on it though...

aewarnick
April 25th, 2005, 10:09 PM
Thanks, but I don't use Microsoft controls, I made my own from scratch.

I just want to know if there is an easier way to get all the desktop files.

NoHero
April 27th, 2005, 11:13 AM
Thanks, but I don't use Microsoft controls, I made my own from scratch.I just want to know if there is an easier way to get all the desktop files.

The desktop itself is a Microsoft control... You have confused me... What do you really need?!

By the way: The Desktop itself is a Listview labeled "FolderView" which is a child of an visible desktop window with the class "SHELLDLL_DefView", which is also a child of the Program Manager.


HWND hFind = NULL;

hFind = FindWindow("Program", "Program Manager");
if ( hFind == NULL )
{
// Handle error
}
hFind = FindWindowEx(hFind, NULL, "SHELLDLL_DefView", NULL);
if ( hFind == NULL )
{
// Handle error
}
hFind = FindWindowEx(hFind, NULL, "SysListView32", "FolderView");
if ( hFind == NULL )
{
// Handle error
}
// If everything worked fine you have the desktop's listview in hFind

aewarnick
April 27th, 2005, 05:36 PM
Found it. Thanks.

SuperKoko
April 27th, 2005, 06:02 PM
The best way to have desktop items, is to use the IShellFolder interface.
Just call the SHGetDesktopFolder function.
You can call IShellFolder::EnumObjects, and IShellFolder::ParseDisplayName.

If you want to get an item icon, you can call GetUIObjectOf with IID_IExtractIcon.
You can also get the context menu, with GetUIObjectOf and IID_IContextMenu.

For more information look at microsoft's documentation of IShellFolder (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/ifaces/ishellfolder/ishellfolder.asp) and SHGetDesktopFolder (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/shgetdesktopfolder.asp)

aewarnick
April 28th, 2005, 02:52 PM
Actually I'm using SHGetSpecialFolderPath to get the desktop location. But you are right on - that's what I was looking for.

Which one is better to use?