Special folder names

Posted on 2006-06-19
Last Modified: 2011-10-03

how can i get the names of special folders like my documents?
Question by:Mark_FreeSoftware
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 26

Expert Comment

ID: 16933752
LVL 13

Author Comment

ID: 16933878

that gives the location, but not the names fo the folders
eg in dutch it is "Mijn Documenten" in english it is "My Documents"
in french it is....


Expert Comment

ID: 16936316
I do not know if this will work for you due to french but it may help you in some way.

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

LVL 13

Author Comment

ID: 16938688

i said already, i do know how to find the folders, but how can i find the local name?

Expert Comment

ID: 16938912
take the last part of the location...
LVL 13

Author Comment

ID: 16938920

that is not a good solution, since some people change the location  (like me, i have it stored in f:\data\documents)

but the local name is Mijn Documenten
LVL 29

Expert Comment

ID: 16939085

Expert Comment

ID: 16939241
good point...

nice find egl1044-it works

you might also want to try:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders

for the other special folders...
LVL 22

Accepted Solution

danaseaman earned 500 total points
ID: 16939869
Try this API version which will return the name in the correct system language:

'In Form (Note CSIDL_PERSONAL is "My Documents")
Private Sub Form_Load()
   MsgBox GetSpecialFolderName(CSIDL_PERSONAL)
End Sub

'In Module:

Option Explicit

Public Enum CSIDL
   CSIDL_DESKTOP = &H0                            ' <desktop>
   CSIDL_INTERNET = &H1                           ' Internet Explorer (icon on desktop)
   CSIDL_PROGRAMS = &H2                           ' Start Menu\Programs
   CSIDL_CONTROLS = &H3                           ' My Computer\Control Panel
   CSIDL_PRINTERS = &H4                           ' My Computer\Printers
   CSIDL_PERSONAL = &H5                           ' My Documents
   CSIDL_FAVORITES = &H6                          ' <user name>\Favorites
   CSIDL_STARTUP = &H7                            ' Start Menu\Programs\Startup
   CSIDL_RECENT = &H8                             ' <user name>\Recent
   CSIDL_SENDTO = &H9                             ' <user name>\SendTo
   CSIDL_BITBUCKET = &HA                          ' <desktop>\Recycle Bin
   CSIDL_STARTMENU = &HB                          ' <user name>\Start Menu
   CSIDL_MYDOCUMENTS = &HC                        ' logical "My Documents" desktop icon
   CSIDL_MYMUSIC = &HD                            ' "My Music" folder
   CSIDL_MYVIDEO = &HE                            ' "My Videos" folder
   CSIDL_DESKTOPDIRECTORY = &H10                  ' <user name>\Desktop
   CSIDL_DRIVES = &H11                            ' My Computer
   CSIDL_NETWORK = &H12                           ' Network Neighborhood (My Network Places)
   CSIDL_NETHOOD = &H13                           ' <user name>\nethood
   CSIDL_FONTS = &H14                             ' windows\fonts
   CSIDL_COMMON_STARTMENU = &H16                  ' All Users\Start Menu
   CSIDL_COMMON_PROGRAMS = &H17                   ' All Users\Start Menu\Programs
   CSIDL_COMMON_STARTUP = &H18                    ' All Users\Startup
   CSIDL_COMMON_DESKTOPDIRECTORY = &H19           ' All Users\Desktop
   CSIDL_APPDATA = &H1A                           ' <user name>\Application Data
   CSIDL_PRINTHOOD = &H1B                         ' <user name>\PrintHood
   CSIDL_LOCAL_APPDATA = &H1C                     ' <user name>\Local Settings\Applicaiton Data (non roaming)
   CSIDL_ALTSTARTUP = &H1D                        ' non localized startup
   CSIDL_COMMON_ALTSTARTUP = &H1E                 ' non localized common startup
   CSIDL_COMMON_APPDATA = &H23                    ' All Users\Application Data
   CSIDL_WINDOWS = &H24                           ' GetWindowsDirectory()
   CSIDL_SYSTEM = &H25                            ' GetSystemDirectory()
   CSIDL_PROGRAM_FILES = &H26                     ' C:\Program Files
   CSIDL_MYPICTURES = &H27                        ' C:\Program Files\My Pictures
   CSIDL_PROFILE = &H28                           ' USERPROFILE
   CSIDL_SYSTEMX86 = &H29                         ' x86 system directory on RISC
   CSIDL_PROGRAM_FILESX86 = &H2A                  ' x86 C:\Program Files on RISC
   CSIDL_PROGRAM_FILES_COMMON = &H2B              ' C:\Program Files\Common
   CSIDL_PROGRAM_FILES_COMMONX86 = &H2C           ' x86 Program Files\Common on RISC
   CSIDL_COMMON_TEMPLATES = &H2D                  ' All Users\Templates
   CSIDL_COMMON_DOCUMENTS = &H2E                  ' All Users\Documents
   CSIDL_COMMON_ADMINTOOLS = &H2F                 ' All Users\Start Menu\Programs\Administrative Tools
   CSIDL_ADMINTOOLS = &H30                        ' <user name>\Start Menu\Programs\Administrative Tools
   CSIDL_CONNECTIONS = &H31                       ' Network and Dial-up Connections
   CSIDL_COMMON_MUSIC = &H35                      ' All Users\My Music
   CSIDL_COMMON_PICTURES = &H36                   ' All Users\My Pictures
   CSIDL_COMMON_VIDEO = &H37                      ' All Users\My Video
   CSIDL_RESOURCES = &H38                         ' Resource Direcotry
   CSIDL_RESOURCES_LOCALIZED = &H39               ' Localized Resource Direcotry
   CSIDL_COMMON_OEM_LINKS = &H3A                  ' Links to All Users OEM specific apps
   CSIDL_CDBURN_AREA = &H3B                       ' USERPROFILE\Local Settings\Application Data\Microsoft\CD Burning
   CSIDL_COMPUTERSNEARME = &H3D                   ' Computers Near Me (computered from Workgroup membership)
End Enum

Private Const SHGFI_DISPLAYNAME = &H200
Private Const SHGFI_PIDL As Long = &H8

Private Declare Function SHGetFileInfoPidlA Lib "shell32" Alias "SHGetFileInfoA" (ByVal pidl As Long, ByVal dwFileAttributes As Long, psfib As SHFILEINFOA, ByVal cbFileInfo As Long, ByVal uFlags As Long) As Long
Private Declare Function SHGetSpecialFolderLocation Lib "shell32" (ByVal hWndOwner As Long, ByVal nFolder As Long, ByRef pidl As Long) As Long
Private Declare Sub CoTaskMemFree Lib "ole32" (ByVal pv As Long)

   hIcon          As Long
   iIcon          As Long
   dwAttributes   As Long
   szDisplayName  As String * 260
   szTypeName     As String * 80
End Type

Public Function GetSpecialFolderName(ByVal pszPath As Long) As String
   Dim lPIDL   As Long
   Dim si      As SHFILEINFOA
   Call SHGetSpecialFolderLocation(0, pszPath, lPIDL)
   Call SHGetFileInfoPidlA(ByVal lPIDL, 0, si, Len(si), SHGFI_PIDL + SHGFI_DISPLAYNAME)
   Call CoTaskMemFree(lPIDL)
   GetSpecialFolderName = StripNull(si.szDisplayName)

End Function

Public Function StripNull(ByVal StrIn As String) As String
   Dim nul              As Long
   nul = InStr(StrIn, vbNullChar)
   Select Case nul
      Case Is > 1
         StripNull = Left$(StrIn, nul - 1)
      Case 1
         StripNull = ""
      Case 0
         StripNull = Trim$(StrIn)
   End Select
End Function

LVL 13

Author Comment

ID: 16940614

that works excellent!

thank you
LVL 13

Author Comment

ID: 16940647

oh and justchat_1:

there i find the registry key "personal", with the contents:


and the key of egl1044:

there is only the key "Mark" (my user name)
with contents:

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

728 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