--
Stanimir
Raymond Chen
Microsoft Corporation
February 2000
Summary: A traditional shell namespace extension requires the implementation of a COM in-process server. Shell instance objects allow you to create simple shell extensions without having to write a single line of code. This article describes how shell instance objects and shell command objects can be used to easily deploy simple shell extensions. (5 printed pages)
What Is a Shell Namespace Extension?
What Is a Shell Instance Object?
Shell Objects That Can Be Created as Shell Instance
Objects
How About an Example?
Shell Command Objects
Conclusion
Shell namespace extensions allow you to create "virtual folders" in the shell. For example, the Recycle Bin icon on the desktop is not an actual file system directory, but rather represents a collection of items that is maintained by the Recycle Bin shell extension.
Details on creating shell namespace extensions can be found in the Platform SDK section of the MSDN Online Library (http://msdn.microsoft.com/library/psdk/shellcc/shell/shell_adv/namespace.htm).
Writing a shell namespace extension can be quite an ordeal. Fortunately, the shell provides an easy way to create certain types of simple shell namespace extensions, as this article will show.
A shell instance object is a special kind of shell extension provided by the shdocvw.dll component. Whereas a traditional shell extension requires a DLL to implement the object, a shell instance object retrieves everything it needs to know from the registry.
How the shell creates a shell instance object
[snip]
> Details on creating shell namespace extensions can be found in
> the Platform SDK section of the MSDN Online Library
>
(http://msdn.microsoft.com/library/psdk/shellcc/shell/shell_adv/name
space.htm).
[snip]
This URL leads me to a "Page Cannot Be Found" page. The other links
aren't functional for me, too. They begin with somewhat strange
(atleast for me) protocol "mk:".
--
Stanimir
--
---------------------------------------------------------------
David Candy
http://www.mvps.org/serenitymacros
http://www.winsite.com/bin/Info?500000002364 or http://www.simtel.com/pub/pd/18669.html
--
http://www.newint.org
---------------------------------------------------------------
"Stanimir Stamenkov" <gri...@muchachos.net> wrote in message news:OrIb8IidCHA.1412@tkmsftngp12...
> This URL leads me to a "Page Cannot Be Found" page. The other
> links aren't functional for me, too. They begin with somewhat
> strange (atleast for me) protocol "mk:".
O.k. I've searched this site http://msdn.microsoft.com for "shell
namespace extension" and found the document... but it seems not an
easy task to handle so much advanced information :-)
--
Stanimir
I've attached a sample file that creates a shell command file (the article describes shell namespace and shell command - they're very similar) that adds notepad to My Computer as a folder. It's 12 lines.
Here's a GUID for you {DE927021-DA63-415E-B4E0-B5811F2FAF9B} to use.
--
---------------------------------------------------------------
David Candy
http://www.mvps.org/serenitymacros
http://www.winsite.com/bin/Info?500000002364 or http://www.simtel.com/pub/pd/18669.html
--
http://www.newint.org
---------------------------------------------------------------
"Stanimir Stamenkov" <gri...@muchachos.net> wrote in message news:#cpD#PidCHA.1608@tkmsftngp12...
--
---------------------------------------------------------------
David Candy
http://www.mvps.org/serenitymacros
http://www.winsite.com/bin/Info?500000002364 or http://www.simtel.com/pub/pd/18669.html
--
http://www.newint.org
---------------------------------------------------------------
"David Candy" <dav...@sia.net.au> wrote in message news:#mEH2aidCHA.3752@tkmsftngp08...
--
---------------------------------------------------------------
David Candy
http://www.mvps.org/serenitymacros
http://www.winsite.com/bin/Info?500000002364 or http://www.simtel.com/pub/pd/18669.html
--
http://www.newint.org
---------------------------------------------------------------
"Stanimir Stamenkov" <gri...@muchachos.net> wrote in message news:#dHI$MjdCHA.1876@tkmsftngp10...
<quote>
Using File System Folders as Junction Points
There are two ways to define file system folders as junction points. The simplest approach is to create a folder in the appropriate location and append a period to the folder's name, followed by the string form of the CLSID of your extension. Only the folder name will be visible in Windows Explorer. The following example creates a junction point with a display name of MyFolder.
MyFolder.{Extension CLSID}
Alternatively, you can define a conventionally named folder as a junction point by:
a.. Making the folder read-only.
b.. Making the folder a system folder by calling PathMakeSystemFolder.
c.. Placing a hidden Desktop.ini file in the folder that includes the extension's CLSID.
Desktop.ini is a standard text file that can be added to any folder to customize certain aspects of the folder's behavior. For a general discussion of how to use this file, see Customizing Folders with Desktop.ini. To define a folder as a junction point, the [.ShellClassInfo] section of Desktop.ini must contain the extension's CLSID as follows:
[.ShellClassInfo]
CLSID={Extension CLSID}
</quote>
It may be the shellfolder flags are wrong. (cos it will junction if I use registry entries on the desktop - but you can only junction to the Desktop, My Computer, or Control Panel [as fonts do])
I've included a reg file to junction it to the desktop.
Here's a list of attributes (add the numbers together in hex. Use calculator in scientifc mode if hex maths is unfamilar to you). Don't worry about anything here other than the table of attributes.
<quote>
IShellFolder::GetAttributesOf
Retrieves the attributes of one or more file objects or subfolders.
HRESULT GetAttributesOf(
UINT cidl,
LPCITEMIDLIST *apidl,
SFGAOF *rgfInOut
);
Parameters
cidl
[in] Number of file objects from which to retrieve attributes.
apidl
[in] Address of an array of pointers to ITEMIDLIST structures, each of which uniquely identifies a file object relative to the parent folder. Each ITEMIDLIST structure must contain exactly one SHITEMID structure followed by a terminating zero.
rgfInOut
[in/out] Address of a single ULONG value that, on entry, contains the attributes that the caller is requesting. On exit, this value contains the requested attributes that are common to all of the specified objects. Note that this is the address of a single ULONG value, not an array of ULONG values. The lists below describe the possible flags for this parameter.
A file object's capability flags may be zero or a combination of the following values:
Flag Value Description
SFGAO_CANCOPY 0x00000001 The specified file objects or folders can be copied (same value as the DROPEFFECT_COPY flag).
SFGAO_CANDELETE 0x00000020 The specified file objects or folders can be deleted.
SFGAO_CANLINK 0x00000004 Shortcuts can be created for the specified file objects or folders. This flag has the same value as DROPEFFECT_LINK. The normal use of this flag is to add a "Create Shortcut" item to the shortcut menu that is displayed during drag-and-drop operations. However, SFGAO_CANLINK also adds a "Create Shortcut" item to the Windows Explorer's File menu, and to normal shortcut menus. If this item is selected, your application's IContextMenu::InvokeCommand will be invoked with the lpVerb member of the CMINVOKECOMMANDINFO structure set to "link". Your application is responsible for creating the link.
SFGAO_CANMONIKER 0x00400000 It is possible to create monikers for the specified file objects or folders.
SFGAO_CANMOVE 0x00000002 The specified file objects or folders can be moved (same value as the DROPEFFECT_MOVE flag).
SFGAO_CANRENAME 0x00000010 The specified file objects or folders can be renamed. Note that this flag is essentially a suggestion. It does not guarantee that a namespace client will rename the file or folder object.
SFGAO_CAPABILITYMASK 0x00000177 This flag is a mask for the capability flags.
SFGAO_DROPTARGET 0x00000100 The specified file objects or folders are drop targets.
SFGAO_HASPROPSHEET 0x00000040 The specified file objects or folders have property sheets.
A file object's display attributes may be zero or a combination of the following values:
Flag Value Description
SFGAO_DISPLAYATTRMASK 0x000F0000 This flag is a mask for the display attributes.
SFGAO_GHOSTED 0x00080000 The specified file objects or folders should be displayed using a ghosted icon.
SFGAO_LINK 0x00010000 The specified file objects are shortcuts.
SFGAO_READONLY 0x00040000 The specified file objects or folders are read-only.
SFGAO_SHARE 0x00020000 The specified folders are shared.
A file object's contents flags may be zero or a combination of the following values:
Flag Value Description
SFGAO_CONTENTSMASK 0x80000000 This flag is a mask for the contents attributes.
SFGAO_HASSUBFOLDER 0x80000000 The specified folders may have subfolders, and are, therefore expandable in the left pane of Windows® Explorer.
Note: The SFGAO_HASSUBFOLDER attribute is only advisory, and may be returned by Shell folder implementations even if they do not contain subfolders. Returning SFGAO_HASSUBFOLDER is recommended whenever a significant amount of time is required to determine whether or not any subfolders exist. For example, the Shell always returns SFGAO_HASSUBFOLDER when a folder is located on a network drive.
A file object's miscellaneous attributes may be zero or a combination of the following values:
Flag Value Description
SFGAO_BROWSABLE 0x08000000 The specified items can be browsed in place.
SFGAO_COMPRESSED 0x04000000 The specified items are compressed.
SFGAO_FILESYSTEM 0x40000000 The specified folders or file objects are part of the file system (that is, they are files, directories, or root directories).
SFGAO_FILESYSANCESTOR 0x10000000 The specified folders contain one or more file system folders.
SFGAO_FOLDER 0x20000000 The specified items are folders.
SFGAO_NEWCONTENT 0x00200000 The objects contain new content.
SFGAO_NONENUMERATED 0x00100000 The items are nonenumerated items.
SFGAO_REMOVABLE 0x02000000 The specified file objects or folders are on removable media.
SFGAO_VALIDATE 0x01000000 Validate cached information. The Shell will validate that the objects specified in apidl still exist and will not use cached information when retrieving the attributes. If one or more of the items specified in apidl no longer exist, this method will return an error code. If cidl is zero, the Shell will discard all cached information for the Shell folder. This is similar to doing a refresh of the folder.
Return Values
Returns NOERROR if successful, or an OLE-defined error value otherwise.
Remarks
You can optimize this operation by not returning unspecified flags.
See Also
IShellFolder
Requirements
Version 4.00 and later of Shell32.dll
Windows NT/2000: Requires Windows NT 4.0 or later.
Windows 95/98/Me: Requires Windows 95 or later.
Header: Declared in Shlobj.h.
</quote>
I'll wait for your comments.
--
---------------------------------------------------------------
David Candy
http://www.mvps.org/serenitymacros
http://www.winsite.com/bin/Info?500000002364 or http://www.simtel.com/pub/pd/18669.html
--
http://www.newint.org
---------------------------------------------------------------
"David Candy" <dav...@sia.net.au> wrote in message news:elnH2ajdCHA.2592@tkmsftngp09...
--
---------------------------------------------------------------
David Candy
http://www.mvps.org/serenitymacros
http://www.winsite.com/bin/Info?500000002364 or http://www.simtel.com/pub/pd/18669.html
--
http://www.newint.org
---------------------------------------------------------------
"David Candy" <dav...@sia.net.au> wrote in message news:#Lfa58jdCHA.1692@tkmsftngp09...
This registry entry have done exactly what I've needed. The other
thing I could want more is to enhance this my custom folder
definition to point not to an absolute location but to a special
folder - the current user profile directory (if there is one, but I
think there should be). In the example with the "Fonts" folder:
*InitPropertyBag*
TargetSpecialFolder=REG_SZ:"0x0024"
could you give me the number for the current user profile directory
or list with the numbers for special folders?
P.S.: Eventually, do you have idea if I could position the
appearance of the folder above "My Computer" in the folders list
(like "My Documents")?
David Candy wrote:
> What you've done is correct. The problem is it won't junction
> using a file system folder (either method).
>
[snip]
>
> It may be the shellfolder flags are wrong. (cos it will junction
> if I use registry entries on the desktop - but you can only
> junction to the Desktop, My Computer, or Control Panel [as fonts
> do])
>
> I've included a reg file to junction it to the desktop.
>
> Here's a list of attributes (add the numbers together in hex. Use
> calculator in scientifc mode if hex maths is unfamilar to you).
> Don't worry about anything here other than the table of
> attributes.
>
[snip]
--
Stanimir
enum ShellSpecialFolderConstants { ssfDESKTOP = 0, ssfPROGRAMS = 0x2, ssfCONTROLS = 0x3, ssfPRINTERS = 0x4, ssfPERSONAL = 0x5, ssfFAVORITES = 0x6, ssfSTARTUP = 0x7, ssfRECENT = 0x8, ssfSENDTO = 0x9, ssfBITBUCKET = 0xa, ssfSTARTMENU = 0xb, ssfDESKTOPDIRECTORY = 0x10, ssfDRIVES = 0x11, ssfNETWORK = 0x12, ssfNETHOOD = 0x13, ssfFONTS = 0x14, ssfTEMPLATES = 0x15, ssfCOMMONSTARTMENU = 0x16, ssfCOMMONPROGRAMS = 0x17, ssfCOMMONSTARTUP = 0x18, ssfCOMMONDESKTOPDIR = 0x19, ssfAPPDATA = 0x1a, ssfPRINTHOOD = 0x1b, ssfLOCALAPPDATA = 0x1c, ssfALTSTARTUP = 0x1d, ssfCOMMONALTSTARTUP = 0x1e, ssfCOMMONFAVORITES = 0x1f, ssfINTERNETCACHE = 0x20, ssfCOOKIES = 0x21, ssfHISTORY = 0x22, ssfCOMMONAPPDATA = 0x23, ssfWINDOWS = 0x24, ssfSYSTEM = 0x25, ssfPROGRAMFILES = 0x26, ssfMYPICTURES = 0x27, ssfPROFILE = 0x28, } ShellSpecialFolderConstants;
EG For My Docs
HKEY_CLASSES_ROOT\CLSID\{450D8FBA-AD25-11D0-
98A8-0800361B1103}
SortOrderIndex
The SortOrderIndex determines the position on the desktop. I have no idea what the numbers mean. If My Docs is first the number is 48 hex and if My docs is not first the number changes to 54 hex.
See if putting a sortorder index on your NSE works, and play with the numbers.
--
---------------------------------------------------------------
David Candy
http://www.mvps.org/serenitymacros
http://www.winsite.com/bin/Info?500000002364 or http://www.simtel.com/pub/pd/18669.html
--
http://www.newint.org
---------------------------------------------------------------
"Stanimir Stamenkov" <om...@muchachos.net> wrote in message news:3DAFF664...@muchachos.net...
The special folder numbers reference and the 'SortOrderIndex' work
like a charm. Now I guess I just have to play a little bit with the
'ShellFolder\Attributes' to make my folder expandable in the folder
pane.
Best Regards,
Stanimir
David Candy wrote:
> Changing the default order, if Explorer uses the same method for
> the folder tree as the desktop, causes wierd errors (at least in
> ME). Done some testing. It does work in the folder tree as well
> as the desktop. The bugs may have been fixed (My Network Places
> didn't crash with My Comp as the first icon).
>
> EG For My Docs
>
> HKEY_CLASSES_ROOT\CLSID\{450D8FBA-AD25-11D0- 98A8-0800361B1103}
> SortOrderIndex
>
> The SortOrderIndex determines the position on the desktop. I have
> no idea what the numbers mean. If My Docs is first the number is
> 48 hex and if My docs is not first the number changes to 54 hex.
>
> See if putting a sortorder index on your NSE works, and play with
> the numbers.
>
>
One last problem (am I getting boring?):
In file open/save/etc. dialogs my folder doesn't appear always in
the files/folders pane if there is filter on the file type, i.e. it
is not recognized as folder at fully (may be).
Would you help me with this one?
Thanks in advance,
Stanimir
Remembering that this is a limited NSE and a specific type of NSE. It may or may not be possible.
There is a KB that talks about this, q216954 which list how to display in file open dialog boxes. I've tried a few things (before I read the article) but it hasn't worked. I haven't tried the article. Q183860 may provide background but is not concerned with this issue.
I have another article that explains more. EMail me and I'll return it by email. Again all of these expect you to be coding your own and don't discuss Shell Instance Objects specifically.
I was looking under HKEY_CLASSES_ROOT\CLSID\{0AFACED1-E828-11D1-9187-B532F1E9575D} in the reg as it is the system object for folder shortcuts. It has different named values and I'd try using them and see what happens. I've found absolutely no documentation (or even it being referred to in passing) for CallForAttributes.
The person who wrote that initial article wrote Tweakui. Maybe an MVP could ask Raymond about it.
Also there are shell programming groups on this server (most people connect to the MS server direct as it's a/ quicker, b/ has the full list of groups). If you were using OE this link would autoconfig OE. Not sure what NS will do.
news://msnews.microsoft.com/microsoft.public.platformsdk.shell
There are a few shell groups so look at one that has a fair amount of traffic as some are old and barely used. (And maybe there are people who have written sample ones that will give it to you).
And please continue to post back to this thread, especially if you solve it.
--
---------------------------------------------------------------
David Candy
http://www.mvps.org/serenitymacros
http://www.winsite.com/bin/Info?500000002364 or http://www.simtel.com/pub/pd/18669.html
--
http://www.newint.org
---------------------------------------------------------------
"Stanimir Stamenkov" <om...@muchachos.net> wrote in message news:3DB01883...@muchachos.net...
--
Stanimir
The items on the start menu are in the registry between these two registry keys
HKEY_CLASSES_ROOT\CLSID\{2559a1f0-21d7-11d4-bdaf-00c04f60b9f0} (this being search)
to
HKEY_CLASSES_ROOT\CLSID\{2559a1f6-21d7-11d4-bdaf-00c04f60b9f0} (this being the Dell one)
Cos most of these entries are of the data type Reg_Expand_SZ Regedit exports them by the hex code for the letter eg A=65, B=66, which makes reading very, very, difficult. So viewing and editing them in Regedit is the preferred way where they are shown in text and oomans can cope.
Normally I would export a reg file and show you what to put where but not much point for regfiles with reg_expand data types. So we need to work in registry edit.
BUT, I know of no way (in regedit) to set the default values data type to reg_expand, as is required. (I use a reg file to set the default data type, then edit it in regedit - the registry is so user friendly - not).
I'm despairing of giving exact instructions here. Perhaps you tell me what you want it to do, and what icon. There are different syntaxes depending on what you want it to do.
--
---------------------------------------------------------------
David Candy
http://www.mvps.org/serenitymacros
http://www.winsite.com/bin/Info?500000002364 or http://www.simtel.com/pub/pd/18669.html
--
http://www.newint.org
---------------------------------------------------------------
"Anando" <anando_c...@online.microsoft.com> wrote in message news:OL4xDb5dCHA.1948@tkmsftngp09...
> Hello David,
>
> I am interested in adding an item on the RHS of the start menu. You know
> some of those DELL computers add their own thing in the start menu ??Well i
> intend to do something like that. It could be a link to anything like a
> folder on my har drive or to my homepage...You had also posted the CLSID
> value earlier (something like {2559....). It would be very kind of you if
> you just tell me how to do it (you know what all to add to instance,
> defaulticon....and all those keys in the rgistry). Please do not give me a
> link to a MSKB article as i am a layman and all that is confsing for me)
>
> Thanx a lot!!
> Anando
>
> "David Candy" <dav...@sia.net.au> wrote in message
> news:eUKale0dCHA.1540@tkmsftngp10...
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.394 / Virus Database: 224 - Release Date: 03-Oct-02
>
>
>
>
>
Thanx for your reply. I assume you must have viewed the screen shot which i
sent as an attachment. Well i wanted to add a link to a folder in my
documents (it is called Internet Downloads). As far as the icon is
concerned...i would like to put an icon from the shell32.dll file (you know
one of the sys icons). I am aware of the CLSID values that you mentioned and
i have gone through the values but i could not make any heads or tails out
of it. Only thing that i could make out was the value "defaulticon". Things
like the "instance" and "shellex" are really confusing.
Any help from your side would be very very helpful. Another thing i might
ask you since you are an MVP. I have just finished school and i will join
college next year...do you think i should prepare and appear for the MCSE
exam ?? And do you think it is going to be of any help while i study in
college in Canada (like getting any campus jobs or something ?)
Thanx a million.
Anando
"David Candy" <dav...@sia.net.au> wrote in message
news:#aMEZb9dCHA.2460@tkmsftngp09...
I have no formal training in computers (but do in Electrical Engineering, Accounting, Welfare Work, and Aging). Just been a hobbyist for 26 years (and a communist for 12). I once saw computers as an agent for social change, empowering local groups to better communicate and organise. As a result of my main jobs (and the volunteer work i did) I end up as a network admin (which I hate, at least after my conversion to the forces of good 12 years ago). Therefore I know little about the MCSE.
--
---------------------------------------------------------------
David Candy
http://www.mvps.org/serenitymacros
http://www.winsite.com/bin/Info?500000002364 or http://www.simtel.com/pub/pd/18669.html
--
http://www.newint.org
---------------------------------------------------------------
"Anando" <anando_c...@online.microsoft.com> wrote in message news:uL31XiSeCHA.2712@tkmsftngp10...