Alexander
Sun Mar 02 18:10:32 CST 2008
Paul Randall schrieb:
> "mayayana" <mayaXXyana1a@mindXXspring.com> wrote in message
> news:%23ztytOueIHA.5620@TK2MSFTNGP04.phx.gbl...
>>> Question: Are all the shell folders with the same title identical,
>>> having the same properties, methods, events, etc, as well as the
>>> same
>>> contents? If not, how can I find out the differences between them?
>>>
>> You might want to check the path instead of
>> the name. There's a current user App Data folder
>> and an All Users App Data folder.
>>
>> I've got this list I made up at one point. I'm
>> not certain it's up to date. I know it's not up
>> to date for Vista, but I think it is for XP. I marked
>> A or U to signify all users or current user:
>>
>> U - Desktop 0
>> U - Start Menu\Programs 2
>> U - Personal 5
>> U - Favorites 6
>> U - Start Menu\Programs\Startup 7
>> U - Recent 8
>> U - SendTo 9
>> Recycle Bin 10
>> U - Start Menu 11
>> Fonts 20
>> U - ShellNew 21
>> A - Start Menu 22
>> A - Start Menu\Programs 23
>> A - Start Menu\Programs\Startup 24
>> All users\Desktop 25
>> U - Application Data 26
>> U - IECache 32
>> Cookies 33
>> History 34
>> A - Application Data 35
>> Windows 36
>> System 37
>> Program Files 38
>> A - ShellNew 45
>> A - documents 46
>> U - start menu\programs\Admin. tools 47
>> A - start menu\programs\Admin. tools 48
>
> Thanks for the info. It took a while to figure out how to find the
> path, but in the process I learned that the .Self property of a
> Shell.Application folder presents a different interface to the same
> folder, an interface that includes a Path property.
That interface is the (Shell)FolderItem interface.
http://msdn2.microsoft.com/en-us/library/bb787810(VS.85).aspx
The Self property kind of a casts the Folder2 object to
a FolderItem object.
http://msdn2.microsoft.com/en-us/library/bb787860(VS.85).aspx
> Now I see that
> duplicate titles are generally associated with a namespace pair for
> the current user and 'all users'.
>
> I am now down to just a few namespaces that appear to be identical:
> Title, NameSpace Number, Path
> Desktop,0,C:\Documents and Settings\Paul\Desktop
> Desktop,16,C:\Documents and Settings\Paul\Desktop
0 is the ssfDESKTOP constant, while 16 resolves ssfDESKTOPDIR.
While the Path points to the same location, there are some practical
differences between both folders:
The ssfDESKTOP shellfolder includes all items that you can see on your
desktop, e.g. "virtual items" such as "My Computer", "My Documentes"
"Recycle Bin" etc (which are special folders themself) and also the
items physically located in ...\All Users\Desktop.
Also it is the root folder of all folders of the Windows Shell.
The ssfDESKTOPDIRECTORY shellfolder includes only the items physically
located in the current users Desktop directory, so these are usually
less items and all items are FS.
Try:
Set sh = CreateObject("Shell.Application")
WSH.Echo sh.Namespace(0).Items.Count
WSH.Echo sh.Namespace(16).Items.Count
> system32,37,C:\WINDOWS\system32
> system32,41,C:\WINDOWS\system32
The constants names are: ssfSYSTEM vs ssfSYSTEMx86.
Namespace and path are the same on a 32-bit system, but
different on a 64-bit machine.
ffr: "ShellSpecialFolderConstants"
http://msdn2.microsoft.com/en-us/library/bb774096(VS.85).aspx
MfG,
Alex
> And I have an oddball Workgroup namespace with a strange path:
> Workgroup,61,Workgroup
>
> Here is my script to list the file system path (where available) for
> all the namespaces accessible via a namespace number:
>
> Option Explicit
> Dim oShApp
> Set oShApp = CreateObject("Shell.Application")
> Dim i, Temp, sItem, oShFolder
> Dim odSpecFldrs
> Set odSpecFldrs = CreateObject("scripting.dictionary")
> odSpecFldrs.comparemode = vbTextCompare
>
> 'Assuming shell namespaces are numbered from 0 to 255,
> ' create a dictionary containing keys consisting of an
> ' alphabetic list of namespace titles followed by a comma
> ' and the namespace number. For example, there may be
> ' keys like: Desktop,0 and Desktop,16 and Desktop,25.
> For i = 0 To 255
> Set oShFolder = oShApp.NameSpace(i)
> If TypeName(oShFolder) <> "Nothing" Then
> odSpecFldrs(i) = oShFolder.Title & "," & i
> On Error Resume Next
> odSpecFldrs(i) = odSpecFldrs(i) & "," & oShFolder.Self.Path
> On Error Goto 0
> End If
> Next 'i
>
> fOverWrite "SpecFolderPaths.txt", _
> Join(SortNet(odSpecFldrs.Items), vbCrLf)
> MsgBox "Done - NameSpace Titles, Numbers and File Paths have " &
> vbCrLf & _
> "been written to file SpecFolderPaths.txt"
>
> Function SortNet(a1DArray)
> Dim i
> With CreateObject ("System.Collections.ArrayList")
> For i = 0 To UBound(a1DArray)
> .Add a1DArray(i)
> Next
> .Sort()
> SortNet = .ToArray
> End With
> End Function
>
> Sub fOverWrite(sFileName, sText)
> With CreateObject("Scripting.FileSystemObject")
> On Error Resume Next
> .CreateTextFile(sFileName, True, False). _
> Write(sText)
> If Err Then 'Try Unicode file.
> On Error GoTo 0
> .CreateTextFile(sFileName, True, True). _
> Write(Text)
> End If
> On Error GoTo 0
> End With
> End Sub
>
> -Paul Randall
>
>