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
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.

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.


Expert Comment

ID: 16937276
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

772 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