Solved

Special folder names

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


how can i get the names of special folders like my documents?
0
Comment
Question by:Mark_FreeSoftware
12 Comments
 
LVL 26

Expert Comment

by:EDDYKT
ID: 16933752
0
 
LVL 13

Author Comment

by:Mark_FreeSoftware
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....

0
 
LVL 5

Expert Comment

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


http://freevbcode.com/ShowCode.Asp?ID=832

0
 
LVL 9

Expert Comment

by:justchat_1
ID: 16937276
0
 
LVL 13

Author Comment

by:Mark_FreeSoftware
ID: 16938688

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

Expert Comment

by:justchat_1
ID: 16938912
take the last part of the location...
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 13

Author Comment

by:Mark_FreeSoftware
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
0
 
LVL 29

Expert Comment

by:nffvrxqgrcfqvvc
ID: 16939085
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DocFolderPaths
0
 
LVL 9

Expert Comment

by:justchat_1
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...
0
 
LVL 22

Accepted Solution

by:
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_TEMPLATES = &H15
   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_FAVORITES = &H1F
   CSIDL_INTERNET_CACHE = &H20
   CSIDL_COOKIES = &H21
   CSIDL_HISTORY = &H22
   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)

Private Type SHFILEINFOA
   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

0
 
LVL 13

Author Comment

by:Mark_FreeSoftware
ID: 16940614

that works excellent!

thank you
0
 
LVL 13

Author Comment

by:Mark_FreeSoftware
ID: 16940647

oh and justchat_1:

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

"f:\data\documents"



and the key of egl1044:

there is only the key "Mark" (my user name)
with contents:
"f:\data\documents"
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

708 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now