Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Open Desktop Items

Posted on 2002-04-22
9
Medium Priority
?
251 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

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 300 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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
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 summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .

810 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