Improve company productivity with a Business Account.Sign Up

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 628
  • Last Modified:

Special folder names

how can i get the names of special folders like my documents?
1 Solution
Mark_FreeSoftwareAuthor Commented:

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

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Mark_FreeSoftwareAuthor Commented:

i said already, i do know how to find the folders, but how can i find the local name?
take the last part of the location...
Mark_FreeSoftwareAuthor Commented:

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

Mark_FreeSoftwareAuthor Commented:

that works excellent!

thank you
Mark_FreeSoftwareAuthor Commented:

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:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now