dcsimg
Results 1 to 23 of 23

Thread: [RESOLVED] Shell and CSIDL Location Constants Defined

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2017
    Posts
    307

    Resolved [RESOLVED] Shell and CSIDL Location Constants Defined

    Found this link that defines the path associated with the CSIDL Constants (may help someone else):
    http://wiki.helpmvp.com/home/notes/windir

    I'm replicating the Vista/Window7 constants here in case the link disappears:

    csidl_profile C:\Users\<user>
    csidl_desktop C:\Users\<user>\Desktop
    csidl_programs C:\Users\<user>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs
    csidl_personal C:\Users\<user>\Documents
    csidl_favorites C:\Users\<user>\Favorites
    csidl_startup C:\Users\<user>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
    csidl_recent C:\Users\<user>\AppData\Roaming\Microsoft\Windows\Recent
    csidl_sendto C:\Users\<user>\AppData\Roaming\Microsoft\Windows\SendTo
    csidl_startmenu C:\Users\<user>\AppData\Roaming\Microsoft\Windows\Start Menu
    csidl_desktopdirectory C:\Users\<user>\Desktop
    csidl_nethood C:\Users\<user>\AppData\Roaming\Microsoft\Windows\Network Shortcuts
    csidl_templates C:\Users\<user>\AppData\Roaming\Microsoft\Windows\Templates
    csidl_appdata C:\Users\<user>\AppData\Roaming
    csidl_printhood C:\Users\<user>\AppData\Roaming\Microsoft\Windows\Printer Shortcuts
    csidl_localappdata C:\Users\<user>\AppData\Local
    csidl_commonfavorites C:\Users\<user>\Favorites
    csidl_internetcache C:\Users\<user>\AppData\Local\Microsoft\Windows\Temporary Internet Files
    csidl_cookies C:\Users\<user>\AppData\Roaming\Microsoft\Windows\Cookies
    csidl_history C:\Users\<user>\AppData\Local\Microsoft\Windows\History
    csidl_mypictures C:\Users\<user>\Pictures
    csidl_admintools C:\Users\<user>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Administrative Tools

    csidl_altstartup C:\Users\<user>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
    csidl_commonaltstartup C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup
    csidl_programfilesx86 C:\Program Files
    csidl_programfilescommonx86 C:\Program Files\Common Files

    csidl_controls
    csidl_printers
    csidl_bitbucket
    csidl_drives
    csidl_network
    csidl_connections

    csidl_windows C:\Windows
    csidl_system C:\Windows\System32
    csidl_programfiles C:\Program Files
    csidl_systemx86 C:\Windows\System32
    csidl_programfilescommon C:\Program Files\Common Files
    csidl_fonts C:\Windows\Fonts

    csidl_commonappdata C:\ProgramData
    csidl_commonstartmenu C:\ProgramData\Microsoft\Windows\Start Menu
    csidl_commonprograms C:\ProgramData\Microsoft\Windows\Start Menu\Programs
    csidl_commonstartup C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup
    csidl_commondesktopdirectory C:\Users\Public\Desktop
    csidl_commontemplates C:\ProgramData\Microsoft\Windows\Templates
    csidl_commonadmintools C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Administrative Tools
    csidl_commondocuments C:\Users\Public\Documents

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Posts
    19,500

    Re: Shell and CSIDL Location Constants Defined

    You can find these along with their actual values in places such as ShlObj_core.h in the Windows SDK or as "Shell Special Folder" constants (ssfXXX) in the type library embedded within Shell32.dll (Microsoft Shell Controls and Automation).

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2017
    Posts
    307

    Re: Shell and CSIDL Location Constants Defined

    dilettante:
    Using the VB IDE you can use the Object Browser to get the constant values as you point out.

    How do you get the Window Path that that constant (name / value) refers to from the VB Object Browser or from Shell32.dll?

  4. #4
    PowerPoster
    Join Date
    Feb 2006
    Posts
    19,500

    Re: Shell and CSIDL Location Constants Defined

    There are a couple of ways. The easiest is to use the Shell objects:

    Code:
        'Late-bind because Microsoft has not preserved binary compatibility
        'between versions of Windows:
        With CreateObject("Shell.Application")
            Debug.Print .NameSpace(ssfWINDOWS).Self.Path
            Debug.Print .NameSpace(ssfCOMMONAPPDATA).Self.Path
            Debug.Print .NameSpace(ssfAPPDATA).Self.Path
            Debug.Print .NameSpace(ssfLOCALAPPDATA).Self.Path
        End With
    However there are flat API calls as well, for example SHGetFolderPath() among others.

  5. #5
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    5,013

    Re: Shell and CSIDL Location Constants Defined

    Just because I've been peeking:

    Code:
    
    Private Const ssfDESKTOP            As Long = &H0&
    Private Const ssfPROGRAMS           As Long = &H2&
    Private Const ssfCONTROLS           As Long = &H3&
    Private Const ssfPRINTERS           As Long = &H4&
    Private Const ssfPERSONAL           As Long = &H5&
    Private Const ssfFAVORITES          As Long = &H6&
    Private Const ssfSTARTUP            As Long = &H7&
    Private Const ssfRECENT             As Long = &H8&
    Private Const ssfSENDTO             As Long = &H9&
    Private Const ssfBITBUCKET          As Long = &HA&
    Private Const ssfSTARTMENU          As Long = &HB&
    Private Const ssfDESKTOPDIRECTORY   As Long = &H10&
    Private Const ssfDRIVES             As Long = &H11&
    Private Const ssfNETWORK            As Long = &H12&
    Private Const ssfNETHOOD            As Long = &H13&
    Private Const ssfFONTS              As Long = &H14&
    Private Const ssfTEMPLATES          As Long = &H15&
    Private Const ssfCOMMONSTARTMENU    As Long = &H16&
    Private Const ssfCOMMONPROGRAMS     As Long = &H17&
    Private Const ssfCOMMONSTARTUP      As Long = &H18&
    Private Const ssfCOMMONDESKTOPDIR   As Long = &H19&
    Private Const ssfAPPDATA            As Long = &H1A&
    Private Const ssfPRINTHOOD          As Long = &H1B&
    Private Const ssfLOCALAPPDATA       As Long = &H1C&
    Private Const ssfALTSTARTUP         As Long = &H1D&
    Private Const ssfCOMMONALTSTARTUP   As Long = &H1E&
    Private Const ssfCOMMONFAVORITES    As Long = &H1F&
    Private Const ssfINTERNETCACHE      As Long = &H20&
    Private Const ssfCOOKIES            As Long = &H21&
    Private Const ssfHISTORY            As Long = &H22&
    Private Const ssfCOMMONAPPDATA      As Long = &H23&
    Private Const ssfWINDOWS            As Long = &H24&
    Private Const ssfSYSTEM             As Long = &H25&
    Private Const ssfPROGRAMFILES       As Long = &H26&
    Private Const ssfMYPICTURES         As Long = &H27&
    Private Const ssfPROFILE            As Long = &H28&
    Private Const ssfSYSTEMx86          As Long = &H29&
    Private Const ssfPROGRAMFILESx86    As Long = &H30&
    
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  6. #6
    PowerPoster
    Join Date
    Feb 2006
    Posts
    19,500

    Re: Shell and CSIDL Location Constants Defined

    Just set a reference to the type library. There is no need to redefine these values, especially not the entire list of them.

    I see people who automate Office programs due the same thing and I have to scratch my head. You can use these typelibs for enums and constants even if you late-bind the objects.

  7. #7
    Lively Member
    Join Date
    Nov 2011
    Posts
    72

    Re: Shell and CSIDL Location Constants Defined

    Code:
    Private Const ssfDesktop = 0
    Private Const ssfPROGRAMS = 1
    Private Const ssfCONTROLS = 3
    Private Const ssfPRINTERS = 4
    Private Const ssfPERSONAL = 5
    Private Const ssfFAVORITES = 6
    Private Const ssfSTARTUP = 7
    Private Const ssfRECENT = 8
    Private Const ssfSENDTO = 9
    Private Const ssfBITBUCKET = 10
    Private Const ssfSTARTMENU = 11
    Private Const ssfDESKTOPDIRECTORY = 16
    Private Const ssfDRIVES = 17
    Private Const ssfNETWORK = 18
    Private Const ssfNETHOOD = 19
    Private Const ssfFONTS = 20
    Private Const ssfTEMPLATES = 21
    Private Const ssfCOMMONSTARTMENU = 22
    Private Const ssfCOMMONPROGRAMS = 23
    Private Const ssfCOMMONSTARTUP = 24
    Private Const ssfCOMMONDESKTOPDIR = 25
    Private Const ssfAPPDATA = 26
    Private Const ssfPRINTHOOD = 27
    Private Const ssfLOCALAPPDATA = 28
    Private Const ssfALTSTARTUP = 29
    Private Const ssfCOMMONALTSTARTUP = 30
    Private Const ssfCOMMONFAVORITES = 31
    Private Const ssfINTERNETCACHE = 32
    Private Const ssfCOOKIES = 33
    Private Const ssfHISTORY = 34
    Private Const ssfCOMMONAPPDATA = 35
    Private Const ssfWINDOWS = 36
    Private Const ssfSYSTEM = 37
    Private Const ssfPROGRAMFILES = 38
    Private Const ssfMYPICTURES = 39
    Private Const ssfPROFILE = 40
    Private Const ssfSYSTEMx86 = 41
    Private Const ssfPROGRAMFILESx86 = 42
    Private Const ssfCommonProgramFiles = 43
    Private Const ssfCommonProgramFilesX86 = 44
    Private Const ssfCommonTemplates = 45
    Private Const ssfCommonDocuments = 46
    Private Const ssfCommonAdminTools = 47
    Private Const ssfAdminTools = 48
    Private Const ssfCommonMusic = 53
    Private Const ssfCommonPictures = 54
    Private Const ssfCommonVideos = 55
    Private Const ssfResources = 56
    Private Const ssfLocalizedResources = 57
    Private Const ssfCommonOemLinks = 58
    Private Const ssfCDBurning = 59
    a few more that i found. can i do it this way?

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2017
    Posts
    307

    Re: Shell and CSIDL Location Constants Defined

    dilettante THANKS:
    That debug.print makes a quick easy reference for my needs at this time.

    Thanks Elroy and k_zeon

    =====================================

    First time messing with the Windows Shell except for shelling a few programs.
    Where I'm going with this FIRST is to try to Pin and UnPin one of my shelled apps from the taskbar
    from within the calling program that shells the App.

    see: http://www.vbforums.com/showthread.p...Not-Retracting

    Reason I wanted all paths for the constants was to peruse the list to see if there is some (general) constant defined for user (programmer) created (and unregistered) folders (directories) which can be used to identify the path to the actual file (exe) so shell can be used to pin/unpin.

    NOTE: Kinda think I'm missing something re Shell and how this pinning process works.
    Last edited by vb6forever; Jan 12th, 2019 at 07:40 PM.

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2017
    Posts
    307

    Re: Shell and CSIDL Location Constants Defined

    Reference: https://docs.microsoft.com/en-us/win...amespace-intro

    From Link:
    Identifying Namespace Objects

    Before you can use a namespace object, you must first have a way of identifying it. An object in the file system could have a name such as MyFile.htm. Because there might be other files with that name elsewhere in the system, uniquely identifying a file or folder requires a fully qualified path such as "C:\MyDocs\MyFile.htm". This path is basically an ordered list of all folders in a path from the file system root, C:\, ending with the file.
    So based on the above the namespace is: path + filename + extension

    However when I do the following the FSO determines the Path exists but fails on Shell Namespace (see code) -- and -- yes I have a reference to Microsoft Shell and Automation.

    Code:
    Private Sub PinTest()
    
       Dim strPath As String
       Dim strFile As String
       Dim strBoth As String
       
       strPath = "C:\YYY\Server"
       strFile = "\AppTest.exe"
       strBoth = strPath & strFile
       If objFSO.FileExists(strBoth) Then
           Set objFolder = objShell.Namespace(strBoth)       '<<fails here (tried strBoth, strPath, and strFile and all return Nothing
           Set objFolderItem = objFolder.ParseName(strFile)
           Set colVerbs = objFolderItem.Verbs
           For Each objVerb In colVerbs
    '           If Replace(objVerb.Name, "&", "") = "Pin to Taskbar" Then objVerb.DoIt
           Next
       End If
    
    End Sub
    Please note that when I have the test App running and Minimized to the taskbar I can pin it manually.
    Last edited by vb6forever; Jan 12th, 2019 at 10:31 PM.

  10. #10
    PowerPoster
    Join Date
    Feb 2006
    Posts
    19,500

    Re: Shell and CSIDL Location Constants Defined

    The NameSpace() method is for folders, not files.

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2017
    Posts
    307

    Re: Shell and CSIDL Location Constants Defined

    It appears pinning can not be done via code (other than possibly VBScript).
    https://docs.microsoft.com/en-us/win...bar-extensions

    A small set of applications are pinned by default for new installations. Other than these, only the user can pin further applications; programmatic pinning by an application is not permitted.

  12. #12
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    2,109

    Re: Shell and CSIDL Location Constants Defined

    Pinning can absolutely be done by code. (You had said this is about Windows 7 right? I'm of course referring to the taskbar, not the Win8/10 big tiles on the start page).

    I'm sorry I made a mistake in the other thread, the verb I gave you was 'startpin' which (successfully) pinned to the Start Menu, instead of the TaskBar. The correct verb is actually taskbarpin. I just double checked it, and it successfully pinned my program to the taskbar. Also confirmed that it will pin any program, it doesn't have to be the currently running one.

    Not sure if your VBScript works, but try it with the taskbarpin verb. Otherwise, my code absolutely works.


  13. #13

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2017
    Posts
    307

    Re: Shell and CSIDL Location Constants Defined

    fafalone:
    Thanks for your response:
    You had said this is about Windows 7 right?
    Correct, but was hoping would work for Win 8, and 10 also.
    Searching for taskbarpin
    FWIW -- if of interest --, came up with this link that addresses Windows 10.
    https://stackoverflow.com/questions/...-in-windows-10

    Prefer a VB rather than VBScript solution, but everytime I put the path to folder in Shell Namespace I get NOTHING back.
    dilettante indicates value s/b the folder Only.
    But example from link above (see below) and other examples show folder and file being used.
    So bit confused.

    Example from link with my VB conversion FAILED.
    Code:
    Public Sub LatestPin()
    'Source:  https://stackoverflow.com/questions/35600392/how-to-get-verb-for-pin-to-taskbar-in-windows-10
    
    '---------
    'VBScript example from link.
    '---------
    'Dim ShellApp, Desktop
    '    ShellApp = CreateObject("Shell.Application")
    '    Desktop = ShellApp.NameSpace("C:\ProgramData\ABC.exe").ParseName("ABC.exe").InvokeVerb("taskbarpin")
    
    
    '----------
    'VB
    '>>>>>>>>  'Method Namespace of IShellDispatch failed.
    '-----------
       Dim ShellApp  As Shell
       
        Set ShellApp = New Shell
        Desktop = ShellApp.NameSpace("C:\Test\Server\App.exe").ParseName("App.exe").InvokeVerb("taskbarpin")  
        
    End Sub
    Last edited by vb6forever; Jan 15th, 2019 at 07:26 PM.

  14. #14
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    2,109

    Re: Shell and CSIDL Location Constants Defined

    Well the start menu and taskbar have radically different functionality from 7 to 8 to 10, so no single solution is going to work everywhere. What you could do is check the OS version and run the corresponding code.

    From your link, taskbarpin apparently works on 8 in addition to 7. For 10, there's a solution in your link too--- a simple search of the forum here will give you plenty of examples of how to create a registry key.

    Regarding the Namespace, take note of dilettante's comment in post #10--- NameSpace refers to folders: ShellApp.NameSpace("C:\ProgramData").ParseName...

  15. #15

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2017
    Posts
    307

    Re: Shell and CSIDL Location Constants Defined

    fafalone:

    Re:
    Desktop = ShellApp.NameSpace("C:\Test\Server\App.exe").ParseName("App.exe").InvokeVerb("taskbarpin")

    In object Browser get up to .InvokeVerb( and asking for a vVerb after that.
    Executing the line with "taskbarpin" get error:
    Expected function or variable
    Removing the File Name from the NameSpace parameter -- using only the folder -- receive the same error (as above) with InvokeVerb highlighted.

    ==============
    IN re to Win10. Manipulating the registry piece of cake compared to this SHELL object.

  16. #16
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    2,109

    Re: Shell and CSIDL Location Constants Defined

    You're using it as a function when InvokeVerb is a Sub.
    Sub InvokeVerb([vVerb])
    Member of Shell32.FolderItem


    instead try
    Set oFolderItem = ShellApp.NameSpace("C:\Test\Server").ParseName("App.exe")
    oFolderItem.InvokeVerb "taskbarpin"


    I feel your pain, I absolutely loathe that awful shell object, to the point where I use much more difficult APIs and shell COM interfaces even when not absolutely necessary, like my way of getting to invoking a verb from your other thread

  17. #17

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2017
    Posts
    307

    Re: Shell and CSIDL Location Constants Defined

    fafalone:

    I feel your pain, I absolutely loathe that awful shell object,
    My sentiments exactly.
    Tried your suggested code last post (#16) and still can't get it to work.
    Obviously I don't get this shell object and how it works.
    Ordered a book on VB Shell last night, so "maybe" it will help -- Hopefully!!!
    Till then will table posts as can't see wasting your time or mine.
    Thanks for all your assistance.

    FWIW - Errored on Set oFolderItem =
    with
    "Object variable or With Block Not Set"
    and my declare for objects is:
    Dim ShellApp As Shell
    Dim oFolderItem As ShellFolderItem

  18. #18
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    2,109

    Re: Shell and CSIDL Location Constants Defined

    Well the full declares/setup for that would be
    Code:
    Dim ShellApp As Shell
    Dim oFolderItem As FolderItem 'or ShellFolderItem, doesn't matter here
    
    Set ShellApp = New Shell
    Set oFolderItem = ShellApp.NameSpace("C:\Test\Server").ParseName("App.exe")
    oFolderItem.InvokeVerb "taskbarpin"
    (with a reference to C:\Windows\SysWOW64\shell32.dll in Project->References (if you're on a 32bit system and don't have SysWOW64, use the one in System32))

    The above is all you need to pin something; just add the reference, copy/paste and run. Confirmed the verb works just the same invoking that way.

  19. #19

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2017
    Posts
    307

    Re: Shell and CSIDL Location Constants Defined

    HURRAY! Working now.

    Dummy (me) had this remmed when I did a rework.
    Code:
    Set ShellApp = New Shell
    THANKS a bunch.
    Hopefully the Shell book will shed some light on "Shell" for future needs.

  20. #20

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2017
    Posts
    307

    Re: [RESOLVED] Shell and CSIDL Location Constants Defined

    One last question.

    Anywhere in Microsoft docs or elsewhere that gives both a picture (graphic) and the associated shell name (object reference).
    One thing I've noticed in researching Shell is the lack of this linkage when trying to understand
    this Shell.
    For example M$ has all the menus (e.g. Right click or whatever when using the desktop or WinExplorer, etc. etc.) that Shell can access or manipulate, but how one refers to them to get/use them is another matter.
    I did write a quicky program to loop the CSIDL constants and dump the associated Path to a listbox so at least have that for starters.
    Last edited by vb6forever; Yesterday at 01:06 PM.

  21. #21
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    2,109

    Re: [RESOLVED] Shell and CSIDL Location Constants Defined

    You're welcome.

    If you're going to be working with shell programming a lot (not the specific object, which has many limitations, but the Windows/Explorer shell in general), I'd recommend looking at my Modern Shell Interfaces Type Library and the large set of sample projects that cover using the newer (i.e. WinXP, especially Vista, and above) methods for doing a lot of what a book on this topic would cover--- for example with this thread's initial topic, on the newest Windows versions, there's special locations that don't have a CSIDL, which is one reason to instead be using FOLDERIDs and KnownFolderManager instead.
    Not sure which book you got but I'd recommend Visual Basic Shell Programming by J.P. Hamilton as well; if you want I have an e-Book of it complete with samples I can send.

  22. #22
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    2,109

    Re: [RESOLVED] Shell and CSIDL Location Constants Defined

    Quote Originally Posted by vb6forever View Post
    One last question.

    Anywhere in Microsoft docs or elsewhere that gives both a picture (graphic) and the associated shell name (object reference).
    One thing I've noticed in researching Shell is the lack of this linkage when trying to understand
    this Shell.
    For example M$ has all the menus (e.g. Right click or whatever when using the desktop or WinExplorer, etc. etc.) that Shell can access or manipulate, but how one refers to them to get/use them is another matter.
    I did write a quicky program to loop the CSIDL constants and dump the associated Path to a listbox so at least have that for starters.
    The "Shell" object in the code from earlier is just a particular library; it's not the only way to access files and folders.
    The menus for example, not through the "Shell" object but through actual shell programming, you can have pop-up on your form, via the IContextMenu interface. See for example the shell browser I wrote, and specifically for the menus the ShowShellContextMenu function within it; or a much simpler project that still loads thumbnails and icons for a file list, my Thumbnail ListView.

  23. #23

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2017
    Posts
    307

    Re: [RESOLVED] Shell and CSIDL Location Constants Defined

    Visual Basic Shell Programming by J.P. Hamilton
    That's the one I purchased - yet to receive.
    Also having an electronic copy would be great if no copyright issues and not to much of a problem for you.

    I'd recommend looking at my Modern Shell Interfaces Type Library and the large set of sample projects
    Had planned to peruse them after reading the book as well as your examples.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width