Welcome to MSDN Blogs Sign in | Join | Help

If you want a menu that shows the contents of the My Computer folder, you already know how to do it

Commenter praful asks what to me is a rather confused question, but I'll try to guess what the real question is.

If you drag My Computer to the Start button in XP, you get an expanding menu that lets you see all files and folders as submenus.

Is this menu available to applications via an API, or do you have to build it yourself? For example, can an application have a pop-up menu, with the My Computer menu in it?

If the My Computer menu is available as an API, is it customisable so that, for example, only folders are displayed and items can be added to the menu?

First of all, if you drag My Computer to the Start button in Windows XP, the result is that the My Computer icon shows up in the pin list as an icon. There is no expanding menu.

You do get an expanding menu if you are using the classic (non-XP) Start menu, so let's assume that praful really asked about the classic Start menu rather than the Windows XP Start menu. But what's so special about My Computer? You can just right-click the Start button, select Open, and then start creating folders. And those folders will show up as expanding menus on the classic Start menu.

That's why I'm confused about this question. It's taking a general feature and focusing on a specific case. There's nothing special about My Computer on the Start menu. It expands like any other folder. It's like asking, "If I create a directory on my floppy drive called stuff, I can use the dir command to look at its contents on the screen. Is this textual format of the contents of the stuff directory available to applications via an API?" What's so special about the stuff directory on your floppy drive? This works for any directory, whether it's on a floppy drive or a hard drive or a network drive.

Anyway, if you want a menu that shows the contents of your My Computer folder, you already know how to do it. It's just a simple matter of typing. You use the IShellFolder::EnumObjects method to enumerate the contents of the My Computer folder. (The linked article shows how to enumerate the contents of the desktop; enumerating the contents of the My Computer folder is left as an exercise.) Since you're in control of the enumeration, you can decide to filter out folders, or show only folders, or show only items whose names end in a vowel. You can show them in a list view, you can show them in a menu, or you can scramble the letters and create a jumble puzzle. It's up to you.

Published Monday, November 19, 2007 7:00 AM by oldnewthing
Filed under:

Comments

# re: If you want a menu that shows the contents of the My Computer folder, you already know how to do it

Monday, November 19, 2007 10:24 AM by e.thermal

Not sure about dragging the my computer icon to the start menu (never even attempted that).  But I use the Desktop toolbar on my taskbar.  When you click on the my computer in the task bar you get my computer opening up(no surprise) but if you hold down control and click on it in the toolbar you get a nice menu that opens up and allows you to drill down into the contents.   Prehaps this is what he was referring to?

# re: If you want a menu that shows the contents of the My Computer folder, you already know how to do it

Monday, November 19, 2007 11:23 AM by Phill

At a guess, I think he was looking for a control he could add to his own application that behaved like the Windows Start Menu so users could browse the hard drive using the menu structure.

He posed the question in a confusing manner alright but I imagine it was another example of asking a question without really thinking about how the solution would work.

# re: If you want a menu that shows the contents of the My Computer folder, you already know how to do it

Monday, November 19, 2007 11:40 AM by Tom

Wow, that's actually kind of cool.  I've never seen the option to browse the hard drive thru a series of nested menus rather than the typical windows explorer interface(s).  I don't know how convenient that would be in reality, but I can see why one might like to add such a feature - especially from a particular (application specific) subfolder.  

# re: If you want a menu that shows the contents of the My Computer folder, you already know how to do it

Monday, November 19, 2007 12:16 PM by SuperKoko

My guess is that this person wasn't aware of shell folders and thought that there was some magic involved for out-of-filesystem shell folders(My computer, control panel, recycled bin, etc.), that might be private to explorer's implementation and undocumented.

His poor understanding of the shell implied a poorly worded question.

(He could have tried to think by himself and seen that explorer treats consistently all its folders)

# re: If you want a menu that shows the contents of the My Computer folder, you already know how to do it

Monday, November 19, 2007 12:49 PM by ak

I guess what he is after is the menu, there is a (undocumented?) set of shell functions that create a menu with the correct icons and everything, just specify a path/PIDL

# re: If you want a menu that shows the contents of the My Computer folder, you already know how to do it

Monday, November 19, 2007 1:36 PM by Weeble

"But what's so special about My Computer? You can just right-click the Start button, select Open, and then start creating folders. And those folders will show up as expanding menus on the classic Start menu."

That doesn't do the same thing. The surprising behaviour is not that folders within the start menu create expanding menus, but that a shortcut to a folder is treated *just like that folder*. There is indeed nothing special about My Computer, but to see the same effect you should be creating shortcuts, not folders.

# re: If you want a menu that shows the contents of the My Computer folder, you already know how to do it

Monday, November 19, 2007 3:06 PM by asdf

# re: If you want a menu that shows the contents of the My Computer folder, you already know how to do it

Monday, November 19, 2007 5:02 PM by David Walker

Wow, the Desktop toolbar is cool.  I have never seen it before reading this message and turning on the Desktop toolbar.

It's NOT like other folders, with its auto-expand stuff.  Maybe that's what the original poster wanted, like ak mentions -- an API that would give him the same auto-expanding menu starting from My Computer, without his having to enumerate everything and build it.

# re: If you want a menu that shows the contents of the My Computer folder, you already know how to do it

Monday, November 19, 2007 5:23 PM by John

@Weeble:  I don't see that behavior.  I create a shortcut to a folder and it always shows up as a shortcut; expanding menus only show up for actual folders.

# re: If you want a menu that shows the contents of the My Computer folder, you already know how to do it

Monday, November 19, 2007 6:39 PM by Neil

John, there are actually two kinds of shortcuts, folder shortcuts (which autoexpand) and regular shortcuts (which don't), although the only way I know of creating a folder shortcut is via the Add Network Place wizard.

You can also give regular folders special names, such as "Control Panel.{CLSID}". You don't actually have to remember the CLSID as Tweak UI will create the correct ones for you.

# re: If you want a menu that shows the contents of the My Computer folder, you already know how to do it

Monday, November 19, 2007 7:34 PM by Dean Harding

I usually create a folder in my profile directory somewhere, with shortcuts to the programs I use frequently. Then, I add it as a toolbar to the taskbar (right-click, Toolbars, New Toolbar...)

Then you just drag it all the way to the right, so all you see is the folder name and a little chevron. Click the chevron and you get cascading a menu of your shortcuts.

Much better than the start menu, I think (though I do still use the "search" in the start menu on vista sometimes)

# re: If you want a menu that shows the contents of the My Computer folder, you already know how to do it

Monday, November 19, 2007 11:09 PM by Mark

Alternatively, with the New XP Start Menu you can right-click the taskbar and choose Properties. From there, the Start Menu tab and click Customize. In that window you can choose whether My Computer is shown on the Start Menu and if it will be a link or expanding menu.

# re: If you want a menu that shows the contents of the My Computer folder, you already know how to do it

Monday, November 19, 2007 11:30 PM by Frank

I read that a long time ago there were some undocumented APIs that would do that for you. I think e.thermal was looking similar to this (the material is quite out of date)

http://www.geocities.com/SiliconValley/4942/filemenu.html

not that I encourage anyone using that in production code or anything though, just FYI...

# re: If you want a menu that shows the contents of the My Computer folder, you already know how to do it

Tuesday, November 20, 2007 3:03 AM by Nick

e.thermal

Thanks for the heads up on the desktop toolbar, I didn't even know it existed until now!  Very useful.

# re: If you want a menu that shows the contents of the My Computer folder, you already know how to do it

Tuesday, November 20, 2007 5:04 AM by Weeble

@John, Neil: Aha, I never knew there were different kinds of shortcuts. I see that if I right-click-and-drag a folder into a folder of my Start menu (on XP, with an XP-style menu), then choose "Create shortcut" in the menu that pops up, I get an expanding "folder shortcut". If I right-click in the folder, choose "New->Shortcut" and then choose a folder, I get a non-expanding "regular shortcut". That's somewhat weird. The "folder shortcut" has no shortcut overlay and has a type of "Folder", but is not a folder. It has a nearly empty properties page. I don't seem to get it when creating shortcuts anywhere outside the start menu.

# re: If you want a menu that shows the contents of the My Computer folder, you already know how to do it

Tuesday, November 20, 2007 5:19 AM by Cavaler

Probably the question was "Must you fill a menu with items yourself or one can just automagically get a HMENU for this (or any) shell folder".

# re: If you want a menu that shows the contents of the My Computer folder, you already know how to do it

Tuesday, November 20, 2007 8:20 AM by RonO

The Desktop toolbar is quite interesting.  The only thing odd about it I can see is that it still shows Internet Explorer as a desktop item even though I've told it not to show IE on the desktop (through TweakUI).

# re: If you want a menu that shows the contents of the My Computer folder, you already know how to do it

Tuesday, November 20, 2007 9:30 AM by John

Hmm.  The Start menu is more complicated than I thought.  I wonder if it is possible to create an infinitely expanding menu.  I.e. have a shortcut to "C:\" on your Start menu, then have another shortcut to "C:\" in "C:\".  I could not do it manually; perhaps it can be done programmatically...

# re: If you want a menu that shows the contents of the My Computer folder, you already know how to do it

Tuesday, November 20, 2007 9:33 AM by John

@Cavaler:  Exactly.  I was thinking something like SHAutoComplete(), only you get the "My Computer" menu instead of auto-complete for an edit window.

# re: If you want a menu that shows the contents of the My Computer folder, you already know how to do it

Tuesday, November 20, 2007 1:33 PM by John

Damn, I couldn't get it to work.  The best I could do was get "Start -> Shortcut to C -> Shortcut to C -> target.lnk".  I guess there is some kind of infinite recursion detection going on.

# re: If you want a menu that shows the contents of the My Computer folder, you already know how to do it

Tuesday, November 20, 2007 11:21 PM by Xepol

What's complicated?  He wanted an API call like "function hmenu CreateMyCOmputerMenu()"

The other way is actually a huge pain.

# re: If you want a menu that shows the contents of the My Computer folder, you already know how to do it

Sunday, November 25, 2007 2:41 PM by praful

Thanks Cavaler and Xepol for succinctly expressing what I required when I asked the question over two years ago! It’s good to know that nothing passes Raymond’s gaze.

At the time, I was writing a shell context menu extension for my program, Space Explorer (http://kaptech.co.uk/se.htm). I wrote Space Explorer years ago when I wanted a cross between Windows File Manager and Explorer. It’s still one of the coolest alternatives to Windows Explorer :-)  I update it every now and then when I’ve got time (the first version came out in 1994). In fact, if you look at the acknowledgements in the help file, you’ll see a certain Raymond Chen and Jeffrey Richter, both of whom have answered questions I’ve had over the years.

Anyway, back to the topic in question. I wanted to add two menu commands to the Windows Explorer context menu: Move To and Copy To – a feature some Linux distros have. Both of these menus would expand showing, you guessed it, My Computer and its subfolders. I wanted to customise it so that, at the bottom of the folder list, I could add a Copy Here or Move Here command. When the user clicked Copy Here or Move Here, the item(s) the user invoked the context menu on in Explorer would be copied or moved.

I actually wrote the program, adding my own shell items as Raymond suggested in his post above but it behaved oddly. After adding many menu items to the Explorer context menu – the submenus nicely expanding on demand to reveal subfolders -, I could not add any more items.

If I remember correctly, when Windows presents the context menu to you, you get a range of idCmds available to you for use in your added menu items. However, if you’re adding My Computer (and its subfolders as a user highlights a folder), you don’t know how many folders exist unless you recursively count them – which would be slow. So if an API existed, Xepol’s CreateMyComputerMenu(), that would be handy.

One day, I hope to do some enhancements for Space Explorer. Does anyone know how I can get around the range problem described above?

New Comments to this post are disabled
 
Page view tracker