Solved

Open Desktop Items

Posted on 2002-04-22
9
241 Views
Last Modified: 2013-12-03
Hi,
I'm making a Desktop kind of program.
It scans the Desktop Folder via:

          if( SHGetDesktopFolder(&pDTF) == NOERROR )
          {
               if( pDTF->EnumObjects(hWnd, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS | SHCONTF_INCLUDEHIDDEN, &pEIL) == NOERROR )
               {
                    while( pEIL->Next(1, &pDTIcon, &uNumIcon) == NOERROR )
                    {
                         if( SHGetFileInfo((LPCTSTR)pDTIcon, 0, &fi, sizeof(fi), SHGFI_DISPLAYNAME | SHGFI_PIDL | SHGFI_ICON | SHGFI_TYPENAME | (bSmall ? SHGFI_SMALLICON : SHGFI_LARGEICON)) )
                         {


It works perfectly

But now my question:
I want to open all of the items in the Desktop Folder (not all at once ofcourse). There are also the items like "My Computer" "Internet Explorer" etc. those are "Sytem Folders" (fi.szTypeName). How can I open/run these system folder types??
The "My Documents" is no problem, I can get the path (SHGetPathFromIDList()) and ShellExecute it, but those other ones??

Can somebody help me?

If the question is too hard for 100 points just let me know!


0
Comment
Question by:KnoppenSpook
  • 4
  • 2
  • 2
  • +1
9 Comments
 

Author Comment

by:KnoppenSpook
ID: 6959990
I'm working is Visual C++
0
 
LVL 86

Expert Comment

by:jkr
ID: 6960006
You'd use 'SHGetSpecialFolderLocation()' together with 'SHGetPathFromIDList()' to open them...
0
 

Author Comment

by:KnoppenSpook
ID: 6960057
when I do this:

     CHAR     szCommand[MAX_PATH+1];
     LPMALLOC      pMem    = NULL;
     LPITEMIDLIST  pSpecFolder = NULL;

     if( SHGetMalloc(&pMem) == NOERROR )
     {
          SHGetSpecialFolderLocation(hWnd,CSIDL_DRIVES,&pSpecFolder);
          SHGetPathFromIDList(pSpecFolder,szCommand);


     }

szCommand is empty :(
0
 

Author Comment

by:KnoppenSpook
ID: 6960083
I'm working is Visual C++
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 3

Expert Comment

by:GGRUNDY
ID: 6964692
As you enumerate throught the contents of the desktop using the "Next" function, you get PIDLs for the items on the desktop returned in the 2nd argument to "Next".
( or at least the Address of an array of ITEMIDLIST pointers).
These PIDLs can be plugged back into the parent directory (the desktop in this case) using pDTF->BindToObject and...
you end up with an IShellFolder interface for the next level down the Namespace hierarchy. You can then EnumObjects on that interface and so on down until you reach the bottom of the tree.

But you will need patience, close attention to whether you've got an ILD, a PIDL or a PILD*. Oh and you will also need plenty of luck.

Cheers
0
 
LVL 3

Expert Comment

by:GGRUNDY
ID: 6964699
PS. I think the PIDLS you get from EnumObjects are always relative to their parent in the namespace so use IBindToObject on the parent IShellFolder not the root IShellFolder.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 6965541
I'm doing it like this:

(1) Call IShellFolder.GetUIObjectOf to get an IContextMenu instance of the context menu of the desktop items.
(2) Call IContextMenu.InvokeCommand to "execute" the item. This should open the item.

Regards, Madshi.
0
 

Author Comment

by:KnoppenSpook
ID: 6972556
It's true, tx, one little question before you get your points :-) Can I just invoke command '0' Or do I have to check wich item of the ContextMenu is "open"
0
 
LVL 20

Accepted Solution

by:
Madshi earned 100 total points
ID: 6972846
Hmmmmm... Let me look in my code again...

Sorry, I should have said that from the beginning. My Delphi code looks something like this (I've shorted it a bit):

procedure ExecuteDefaultItem(cm: IContextMenu; parentWnd: dword);
var ici  : TCMInvokeCommandInfo;
    menu : dword;
begin
  menu := CreatePopupMenu;
  try
    zeroMemory(@ici,sizeOf(ici));
    with ici do begin
      cbSize := sizeOf(TCMInvokeCommandInfo);
      fMask  := CMIC_MASK_FLAG_NO_UI;
      hwnd   := parentWnd;
      nShow  := SW_SHOW;
    end;
    cm.QueryContextMenu(menu, 0, 1, $7FFF, CMF_DEFAULTONLY);
    ici.lpVerb := pchar(GetMenuDefaultItem(menu, 0, 0) - 1);
    cm.InvokeCommand(ici);
  finally DestroyMenu(menu) end;
end;

Regards, Madshi.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This video discusses moving either the default database or any database to a new volume.

708 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

14 Experts available now in Live!

Get 1:1 Help Now