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.

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month3 days, 21 hours left to enroll

630 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