Solved

Open Desktop Items

Posted on 2002-04-22
9
246 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
[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
  • 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

Author Comment

by:KnoppenSpook
ID: 6960083
I'm working is Visual C++
0
 
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

724 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