Solved

Open Desktop Items

Posted on 2002-04-22
9
242 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
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…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

920 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

15 Experts available now in Live!

Get 1:1 Help Now